public void DeletePortmanta(DeleteIzdelieBindingModel model) { Portmanto portmanto = this.Context.Portmanta.Find(model.Id); this.Context.Portmanta.Remove(portmanto); this.Context.SaveChanges(); }
public DeleteProductViewModel GetDeletePortmantoViewModel(int id) { Portmanto portmanto = this.Context.Portmanta.Find(id); DeleteProductViewModel model = Mapper.Map <Portmanto, DeleteProductViewModel>(portmanto); return(model); }
public FullProductViewModel GetPortmantoById(int id) { Portmanto portmanto = this.Context.Portmanta.Find(id); FullProductViewModel model = Mapper.Map <Portmanto, FullProductViewModel>(portmanto); return(model); }
public void AddPortmanta(IzdeliqBindingModel model) { Portmanto portmanto = new Portmanto() { 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); portmanto.Supplier = supplier; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { portmanto.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.Portmanta.Add(portmanto); this.Context.SaveChanges(); }
public void EditPortmanta(EditIzdlieBindingModel model) { Portmanto portmanto = this.Context.Portmanta.Find(model.Id); portmanto.CatNumber = model.CatNumber; portmanto.Color = model.Color; portmanto.Description = model.Description; portmanto.NalichnostBr = model.NalichnostBr; portmanto.Name = model.Name; portmanto.Price = model.Price; portmanto.Razmeri = model.Razmeri; portmanto.Type = model.Type; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { portmanto.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.SaveChanges(); }