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