public FullProductViewModel GetSpalnqById(int id) { Spalnq spalnq = this.Context.Spalni.Find(id); FullProductViewModel model = Mapper.Map <Spalnq, FullProductViewModel>(spalnq); return(model); }
public void AddSpalnq(IzdeliqBindingModel model) { Spalnq spalnq = new Spalnq() { 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); spalnq.Supplier = supplier; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { spalnq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.Spalni.Add(spalnq); this.Context.SaveChanges(); }
public void DeleteSpalnq(DeleteIzdelieBindingModel model) { Spalnq spalnq = this.Context.Spalni.Find(model.Id); this.Context.Spalni.Remove(spalnq); this.Context.SaveChanges(); }
public DeleteProductViewModel GetDeleteSpalnqViewModel(int id) { Spalnq spalnq = this.Context.Spalni.Find(id); DeleteProductViewModel model = Mapper.Map <Spalnq, DeleteProductViewModel>(spalnq); return(model); }
public void AddSpalnq(IzdeliqBindingModel model) { Spalnq spalnq = new Spalnq() { CatNumber = model.CatNumber, Color = model.Color, Description = model.Description, Price = model.Price, Name = model.Name, Razmeri = model.Razmeri, Type = model.Type, NalichnostBr = model.NalichnostBr }; this.Context.Spalni.Add(spalnq); }
public void EditSpalnq(EditIzdlieBindingModel model) { Spalnq spalnq = this.Context.Spalni.Find(model.Id); spalnq.CatNumber = model.CatNumber; spalnq.Color = model.Color; spalnq.Description = model.Description; spalnq.NalichnostBr = model.NalichnostBr; spalnq.Name = model.Name; spalnq.Price = model.Price; spalnq.Razmeri = model.Razmeri; spalnq.Type = model.Type; if (model.ImageName != null && model.ImageName.ContentLength > 0) { using (var reader = new BinaryReader(model.ImageName.InputStream)) { spalnq.ImagePicture = reader.ReadBytes(model.ImageName.ContentLength); } } this.Context.SaveChanges(); }