public Model.CostCenter UpdateCostCenter(Model.CostCenter costCenter) { var costCenterToUpdate = _dbContext.CostCenters .FirstOrDefault(x => x.Id == costCenter.Id.GetValueOrDefault() && x.RecordStatus == true); costCenterToUpdate.Description = costCenter.Description; costCenterToUpdate.Name = costCenter.Name; costCenterToUpdate.UpdateDate = DateTime.Now; _dbContext.SaveChanges(); return(costCenter); }
public Model.CostCenter SaveCostCenter(Model.CostCenter costCenter) { CostCenter costCenterToSave = new CostCenter { Description = costCenter.Description, Name = costCenter.Name }; _dbContext.CostCenters.Add(costCenterToSave); _dbContext.SaveChanges(); costCenter.Id = costCenterToSave.Id; return(costCenter); }