public async Task <bool> Create(InventoryHistory InventoryHistory) { InventoryHistoryDAO InventoryHistoryDAO = new InventoryHistoryDAO(); InventoryHistoryDAO.Id = InventoryHistory.Id; InventoryHistoryDAO.InventoryId = InventoryHistory.InventoryId; InventoryHistoryDAO.OldSaleStock = InventoryHistory.OldSaleStock; InventoryHistoryDAO.SaleStock = InventoryHistory.SaleStock; InventoryHistoryDAO.OldAccountingStock = InventoryHistory.OldAccountingStock; InventoryHistoryDAO.AccountingStock = InventoryHistory.AccountingStock; InventoryHistoryDAO.AppUserId = InventoryHistory.AppUserId; InventoryHistoryDAO.CreatedAt = StaticParams.DateTimeNow; InventoryHistoryDAO.UpdatedAt = StaticParams.DateTimeNow; DataContext.InventoryHistory.Add(InventoryHistoryDAO); await DataContext.SaveChangesAsync(); InventoryHistory.Id = InventoryHistoryDAO.Id; await SaveReference(InventoryHistory); return(true); }
public async Task <bool> BulkMerge(List <InventoryHistory> InventoryHistories) { List <InventoryHistoryDAO> InventoryHistoryDAOs = new List <InventoryHistoryDAO>(); foreach (InventoryHistory InventoryHistory in InventoryHistories) { InventoryHistoryDAO InventoryHistoryDAO = new InventoryHistoryDAO(); InventoryHistoryDAO.Id = InventoryHistory.Id; InventoryHistoryDAO.InventoryId = InventoryHistory.InventoryId; InventoryHistoryDAO.OldSaleStock = InventoryHistory.OldSaleStock; InventoryHistoryDAO.SaleStock = InventoryHistory.SaleStock; InventoryHistoryDAO.OldAccountingStock = InventoryHistory.OldAccountingStock; InventoryHistoryDAO.AccountingStock = InventoryHistory.AccountingStock; InventoryHistoryDAO.AppUserId = InventoryHistory.AppUserId; InventoryHistoryDAO.CreatedAt = StaticParams.DateTimeNow; InventoryHistoryDAO.UpdatedAt = StaticParams.DateTimeNow; InventoryHistoryDAOs.Add(InventoryHistoryDAO); } await DataContext.BulkMergeAsync(InventoryHistoryDAOs); return(true); }
public async Task <bool> Update(InventoryHistory InventoryHistory) { InventoryHistoryDAO InventoryHistoryDAO = DataContext.InventoryHistory.Where(x => x.Id == InventoryHistory.Id).FirstOrDefault(); if (InventoryHistoryDAO == null) { return(false); } InventoryHistoryDAO.Id = InventoryHistory.Id; InventoryHistoryDAO.InventoryId = InventoryHistory.InventoryId; InventoryHistoryDAO.OldSaleStock = InventoryHistory.OldSaleStock; InventoryHistoryDAO.SaleStock = InventoryHistory.SaleStock; InventoryHistoryDAO.OldAccountingStock = InventoryHistory.OldAccountingStock; InventoryHistoryDAO.AccountingStock = InventoryHistory.AccountingStock; InventoryHistoryDAO.AppUserId = InventoryHistory.AppUserId; InventoryHistoryDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.SaveChangesAsync(); await SaveReference(InventoryHistory); return(true); }