public void DeleteKuhni(DeleteIzdelieBindingModel model) { Kuhnq kuhnq = this.Context.Kuhni.Find(model.Id); this.Context.Kuhni.Remove(kuhnq); this.Context.SaveChanges(); }
public DeleteProductViewModel GetDeleteKuhnqViewModel(int id) { Kuhnq kuhnq = this.Context.Kuhni.Find(id); DeleteProductViewModel model = Mapper.Map <Kuhnq, DeleteProductViewModel>(kuhnq); return(model); }
public FullProductViewModel GetKuhnqById(int id) { Kuhnq kuhnq = this.Context.Kuhni.Find(id); FullProductViewModel model = Mapper.Map <Kuhnq, FullProductViewModel>(kuhnq); return(model); }
public void AddKuhni(IzdeliqBindingModel model) { Kuhnq kuhnq = new Kuhnq() { 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); kuhnq.Supplier = supplier; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { kuhnq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.Kuhni.Add(kuhnq); this.Context.SaveChanges(); }
public void EditKuhni(EditIzdlieBindingModel model) { Kuhnq kuhnq = this.Context.Kuhni.Find(model.Id); kuhnq.CatNumber = model.CatNumber; kuhnq.Color = model.Color; kuhnq.Description = model.Description; kuhnq.NalichnostBr = model.NalichnostBr; kuhnq.Name = model.Name; kuhnq.Price = model.Price; kuhnq.Razmeri = model.Razmeri; kuhnq.Type = model.Type; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { kuhnq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.SaveChanges(); }