public void IdentificationDocumentUpdate(Guid employeeId, EmployeeIdentificationDocumentModel model) { var userId = this.GetCurrentUserId(); if ((model.id ?? Guid.Empty) != Guid.Empty) { this._repoEmployeeIdentificationDocument.FindAndUpdateFromModel(model, model.id.Value) .SetValue(x => x.identificationDocumentId, model.IdentificationDocument.value) .SetValue(x => x.idNumber, model.idNumber) .SetValue(x => x.updatedBy, userId) .SetValue(x => x.updatedDate, DateTime.Now) .Update(); this._unitOfWork.Save(); } else { var ins = this._repoEmployeeIdentificationDocument.Insert(new mf_EmployeeIdentificationDocument() { employeeId = employeeId, idNumber = model.idNumber, identificationDocumentId = model.IdentificationDocument.value, updatedBy = userId, }); this._unitOfWork.Save(); model.id = ins.id; } }
public ActionResult IdentificationDocumentCRUD([DataSourceRequest] DataSourceRequest request , Guid employeeId , UpdateType updateType , EmployeeIdentificationDocumentModel model) { if (model != null && ModelState.IsValid) { try { switch (updateType) { case UpdateType.Create: case UpdateType.Update: this._employeeService.IdentificationDocumentUpdate(employeeId, model); model = this._employeeService.IdentificationDocumentList(employeeId).FirstOrDefault(x => x.id == model.id); break; case UpdateType.Destroy: this._employeeService.IdentificationDocumentDelete(model.id.Value); break; default: break; } } catch (Exception ex) { this.AddModelError(ex); } } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }