public async Task <bool> Create(CustomerPointHistory CustomerPointHistory) { CustomerPointHistoryDAO CustomerPointHistoryDAO = new CustomerPointHistoryDAO(); CustomerPointHistoryDAO.Id = CustomerPointHistory.Id; CustomerPointHistoryDAO.CustomerId = CustomerPointHistory.CustomerId; CustomerPointHistoryDAO.TotalPoint = CustomerPointHistory.TotalPoint; CustomerPointHistoryDAO.CurrentPoint = CustomerPointHistory.CurrentPoint; CustomerPointHistoryDAO.ChangePoint = CustomerPointHistory.ChangePoint; CustomerPointHistoryDAO.IsIncrease = CustomerPointHistory.IsIncrease; CustomerPointHistoryDAO.Description = CustomerPointHistory.Description; CustomerPointHistoryDAO.ReduceTotal = CustomerPointHistory.ReduceTotal; CustomerPointHistoryDAO.CreatedAt = StaticParams.DateTimeNow; CustomerPointHistoryDAO.UpdatedAt = StaticParams.DateTimeNow; DataContext.CustomerPointHistory.Add(CustomerPointHistoryDAO); await DataContext.SaveChangesAsync(); CustomerPointHistory.Id = CustomerPointHistoryDAO.Id; await SaveReference(CustomerPointHistory); return(true); }
public async Task <bool> BulkMerge(List <CustomerPointHistory> CustomerPointHistories) { List <CustomerPointHistoryDAO> CustomerPointHistoryDAOs = new List <CustomerPointHistoryDAO>(); foreach (CustomerPointHistory CustomerPointHistory in CustomerPointHistories) { CustomerPointHistoryDAO CustomerPointHistoryDAO = new CustomerPointHistoryDAO(); CustomerPointHistoryDAO.Id = CustomerPointHistory.Id; CustomerPointHistoryDAO.CustomerId = CustomerPointHistory.CustomerId; CustomerPointHistoryDAO.TotalPoint = CustomerPointHistory.TotalPoint; CustomerPointHistoryDAO.CurrentPoint = CustomerPointHistory.CurrentPoint; CustomerPointHistoryDAO.ChangePoint = CustomerPointHistory.ChangePoint; CustomerPointHistoryDAO.IsIncrease = CustomerPointHistory.IsIncrease; CustomerPointHistoryDAO.Description = CustomerPointHistory.Description; CustomerPointHistoryDAO.ReduceTotal = CustomerPointHistory.ReduceTotal; CustomerPointHistoryDAO.CreatedAt = StaticParams.DateTimeNow; CustomerPointHistoryDAO.UpdatedAt = StaticParams.DateTimeNow; CustomerPointHistoryDAOs.Add(CustomerPointHistoryDAO); } await DataContext.BulkMergeAsync(CustomerPointHistoryDAOs); return(true); }
public async Task <bool> Update(CustomerPointHistory CustomerPointHistory) { CustomerPointHistoryDAO CustomerPointHistoryDAO = DataContext.CustomerPointHistory.Where(x => x.Id == CustomerPointHistory.Id).FirstOrDefault(); if (CustomerPointHistoryDAO == null) { return(false); } CustomerPointHistoryDAO.Id = CustomerPointHistory.Id; CustomerPointHistoryDAO.CustomerId = CustomerPointHistory.CustomerId; CustomerPointHistoryDAO.TotalPoint = CustomerPointHistory.TotalPoint; CustomerPointHistoryDAO.CurrentPoint = CustomerPointHistory.CurrentPoint; CustomerPointHistoryDAO.ChangePoint = CustomerPointHistory.ChangePoint; CustomerPointHistoryDAO.IsIncrease = CustomerPointHistory.IsIncrease; CustomerPointHistoryDAO.Description = CustomerPointHistory.Description; CustomerPointHistoryDAO.ReduceTotal = CustomerPointHistory.ReduceTotal; CustomerPointHistoryDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.SaveChangesAsync(); await SaveReference(CustomerPointHistory); return(true); }