public bool UpdateMaterial(int id, MaterialFormModel data) { Material materialFromDB = _context.Material.Find(id); if (materialFromDB == null) { return(false); } data.MaterialId = id; _context.Entry(materialFromDB).CurrentValues.SetValues(data); _context.SaveChanges(); return(true); }
public MaterialModel CreateMaterial(MaterialFormModel data) { Material newMaterial = new Material(); _context.Material.Add(newMaterial); _context.Entry(newMaterial).CurrentValues.SetValues(data); _context.SaveChanges(); return(new MaterialModel { MaterialId = newMaterial.MaterialId, SupplierId = newMaterial.SupplierId, Name = newMaterial.Name, MinStock = newMaterial.MinStock, PackagingSize = newMaterial.PackagingSize, Unit = newMaterial.Unit, Price = newMaterial.Price, Supplier = newMaterial.Supplier }); }
public bool UpdateMaterial(int id, [FromBody] MaterialFormModel data) { return(this._context.UpdateMaterial(id, data)); }
public MaterialModel CreateMaterial([FromBody] MaterialFormModel data) { return(this._context.CreateMaterial(data)); }