public void Create(SupplierProductEntity item) { using (var context = new DatabaseContext()) { var e = new SupplierProduct(); e.SupplierID = item.SupplierID; e.ProductID = item.ProductID; e.Stock = item.Stock; e.SRP = item.SRP; e.Status = item.Status; e.CreatedBy = item.CreatedBy; e.CreatedDate = item.CreatedDate; e.ModifiedBy = item.ModifiedBy; e.ModifiedDate = item.ModifiedDate; context.SupplierProducts.Add(e); context.SaveChanges(); item.ID = e.ID; } }
public void Update(SupplierProductEntity item) { using (var context = new DatabaseContext()) { var e = context.SupplierProducts.SingleOrDefault(o => o.ID == item.ID); if (e != null) { e.SupplierID = item.SupplierID; e.ProductID = item.ProductID; e.Stock = item.Stock; e.SRP = item.SRP; e.Status = item.Status; e.CreatedBy = item.CreatedBy; e.CreatedDate = item.CreatedDate; e.ModifiedBy = item.ModifiedBy; e.ModifiedDate = item.ModifiedDate; context.SaveChanges(); } } }
public static StockModel MapModel(SupplierProductEntity item) { if (item != null) { return new StockModel() { ID = item.ID, ProdID = item.ProductID, SupID = item.SupplierID, ProdName = item.ProductName, SupName = item.SupplierName, Quantity = item.Stock, Price = item.SRP, Status = item.Status, CreatedBy = item.CreatedBy, CratedDate = item.CreatedDate, } } ; else { return(new StockModel()); } }
public static SupplierProductComModel MaptoModel(SupplierProductEntity item) { if (item != null) { return new SupplierProductComModel() { ID = item.ID, SupplierID = item.SupplierID, ProductID = item.ProductID, Stock = item.Stock, SRP = item.SRP, Status = item.Status, CreatedBy = item.CreatedBy, CreatedDate = item.CreatedDate, ModifiedBy = item.ModifiedBy, ModifiedDate = item.ModifiedDate } } ; else { return(default(SupplierProductComModel)); } }