public void DeductionUpdate(Guid employeeId, EmployeeDeductionModel model) { var userId = this.GetCurrentUserId(); UpdateEntity <EmployeeDeductionModel, mf_EmployeeDeduction> ue; if ((model.id ?? Guid.Empty) != Guid.Empty) { ue = this._repoEmployeeDeduction.FindAndUpdateFromModel(model, model.id.Value); ue.Update(); } else { ue = this._repoEmployeeDeduction.PrepareEntity(model); ue.Insert(); } ue.IgnoreErrorSetValue() .MatchAllDataField() .SetValue(x => x.employeeId, employeeId) .SetValue(x => x.deductionId, model.Deduction.value) .SetValue(x => x.updatedBy, userId) .SetValue(x => x.updatedDate, DateTime.Now); var ent = ue.GetEntity(); this._unitOfWork.Save(); model.id = ent.id; }
public ActionResult DeductionCRUD([DataSourceRequest] DataSourceRequest request, Guid employeeId, UpdateType updateType, EmployeeDeductionModel model) { if (model != null && ModelState.IsValid) { try { switch (updateType) { case UpdateType.Create: case UpdateType.Update: this._employeeService.DeductionUpdate(employeeId, model); model = this._employeeService.DeductionList(employeeId).FirstOrDefault(x => x.id == model.id); break; case UpdateType.Destroy: this._employeeService.DeductionDelete(model.id.Value); break; default: break; } } catch (Exception ex) { this.AddModelError(ex); } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }