public ActionResult Costs_Update([DataSourceRequest] DataSourceRequest request, CostViewModel custVM) { if (custVM != null && ModelState.IsValid) { var cust = _costTasks.One(custVM.CostID); if (cust != null) { ConvertToCost(custVM, cust); cust.ModifiedDate = DateTime.Now; cust.ModifiedBy = User.Identity.Name; cust.DataStatus = "Updated"; _costTasks.Update(cust); } } return(Json(ModelState.ToDataSourceResult())); }
private void ConvertToTProjectCost(TProjectCostViewModel vm, TProjectCost entity) { entity.CostId = string.IsNullOrEmpty(vm.CostId) ? null : _MCostTasks.One(vm.CostId); entity.EquipId = string.IsNullOrEmpty(vm.EquipId) ? null : _MEquipTasks.One(vm.EquipId); entity.ProjectId = string.IsNullOrEmpty(vm.ProjectId) ? null : _TProjectTasks.One(vm.ProjectId); entity.ProjectCostDate = vm.ProjectCostDate; entity.ProjectCostQty = vm.ProjectCostQty; entity.ProjectCostTotal = vm.ProjectCostQty * vm.ProjectCostPrice; entity.ProjectCostDesc = vm.ProjectCostDesc; entity.ProjectCostPrice = vm.ProjectCostPrice; }