public void Create(StockItemDTO stockItemDTO) { Item_Stock item_Stock = new Item_Stock(); item_Stock.Item_Name = stockItemDTO.Item_Name; item_Stock.Item_Quantity = stockItemDTO.Item_Quantity; item_Stock.Item_Disposed_On = stockItemDTO.Item_Disposed_On; item_Stock.Item_Purchased_On = stockItemDTO.Item_Purchased_On; item_Stock.Item_Remarks = stockItemDTO.Item_Remarks; item_Stock.Store_ID = stockItemDTO.Store_ID; dbcontext.Item_Stock.Add(item_Stock); dbcontext.SaveChanges(); }
public void Edit(StockItemDTO stockItemDTO) { Item_Stock item_Stock = new Item_Stock(); item_Stock.Item_ID = stockItemDTO.Item_ID; item_Stock.Item_Name = stockItemDTO.Item_Name; item_Stock.Item_Quantity = stockItemDTO.Item_Quantity; item_Stock.Item_Purchased_On = stockItemDTO.Item_Purchased_On; item_Stock.Item_Disposed_On = stockItemDTO.Item_Disposed_On; item_Stock.Item_Remarks = stockItemDTO.Item_Remarks; item_Stock.Store_ID = stockItemDTO.Store_ID; dbcontext.Entry(item_Stock).State = EntityState.Modified; dbcontext.SaveChanges(); }
public bool Delete(int id) { if (dbcontext.Item_Stock.Any(i => i.Item_ID == id)) { Item_Stock item_Stock = new Item_Stock(); item_Stock.Item_ID = id; dbcontext.Entry(item_Stock).State = EntityState.Deleted; dbcontext.SaveChanges(); return(true); } else { return(false); } }