using System; using System.Collections.Generic; using System.IO; using F = DataFactory.Factory; //Generic data factory using W = DataFactory.Workers; //specific data workers using M = DataFactory.Models; //specific BLL models namespace CustomControls.Projections { // easy to access in UIL public class Upload { public int Id { get; set; } public string FileName { get; set; } public byte[] File { get; set; } public int? SupplierId { get; set; } public MemoryStream ToStream() { // just coz it's easier to read when I use it. Some files (not these) will need to be read in from a file system etc. return new MemoryStream(File); } public static List<Upload> SelectAll() { return F.DataFactory<W.Upload>.SelectAll<M.Upload>().ConvertAll(Converter); } public static Upload SelectById(int id) { return Converter(F.DataFactory<W.Upload>.SelectById<M.Upload>(id)); } public static int Save(Upload item, bool updateRelated = false) { return F.DataFactory<W.Upload>.Save<int>(Converter(item), updateRelated); } private static M.Upload Converter(Upload arg) { if (arg == null) return null; return new M.Upload { Id = arg.Id, FileName = arg.FileName, File = arg.File, SupplierId = arg.SupplierId }; } private static Upload Converter(M.Upload arg) { if (arg == null) return null; return new Upload { Id = arg.Id, FileName = arg.FileName, File = arg.File, SupplierId = arg.SupplierId }; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)