public FullProductViewModel GetSekciqById(int id) { Sekciq sekciq = this.Context.Sekcii.Find(id); FullProductViewModel model = Mapper.Map <Sekciq, FullProductViewModel>(sekciq); return(model); }
public DeleteProductViewModel GetDeleteSekciqViewModel(int id) { Sekciq sekciq = this.Context.Sekcii.Find(id); DeleteProductViewModel model = Mapper.Map <Sekciq, DeleteProductViewModel>(sekciq); return(model); }
public void DeleteSekcii(DeleteIzdelieBindingModel model) { Sekciq sekciq = this.Context.Sekcii.Find(model.Id); this.Context.Sekcii.Remove(sekciq); this.Context.SaveChanges(); }
public void AddSekcii(IzdeliqBindingModel model) { Sekciq sekciq = new Sekciq() { CatNumber = model.CatNumber, Color = model.Color, Description = model.Description, Price = model.Price, Name = model.Name, Razmeri = model.Razmeri, Type = model.Type, NalichnostBr = model.NalichnostBr }; Supplier supplier = this.Context.Suppliers.Find(model.SupplierId); sekciq.Supplier = supplier; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { sekciq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.Sekcii.Add(sekciq); this.Context.SaveChanges(); }
public void EditSekcii(EditIzdlieBindingModel model) { Sekciq sekciq = this.Context.Sekcii.Find(model.Id); sekciq.CatNumber = model.CatNumber; sekciq.Color = model.Color; sekciq.Description = model.Description; sekciq.NalichnostBr = model.NalichnostBr; sekciq.Name = model.Name; sekciq.Price = model.Price; sekciq.Razmeri = model.Razmeri; sekciq.Type = model.Type; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { sekciq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.SaveChanges(); }