public void SectionUpdate(DepartmentSectionModel model) { var upt = this._repoDepartmentSection.Find(model.id); upt.code = model.code; upt.departmentId = model.department.value; upt.description = model.description; upt.updatedBy = this.GetCurrentUserId(); upt.updatedDate = DateTime.Now; this._repoDepartmentSection.Update(upt); this._unitOfWork.Save(); }
public void SectionCreate(DepartmentSectionModel model, out Guid departmentSectionId) { var currentUserId = this.GetCurrentUserId(); var ins = this._repoDepartmentSection.Insert(new mf_DepartmentSection() { code = model.code, description = model.description, updatedBy = currentUserId, departmentId = model.department.value, }); this._unitOfWork.Save(); departmentSectionId = ins.id; }
public ActionResult DepartmentSectionCRUD([DataSourceRequest] DataSourceRequest request , UpdateType updateType , DepartmentSectionModel model) { if (model != null && ModelState.IsValid) { try { switch (updateType) { case UpdateType.Create: Guid departmentId; this._departmentService.SectionCreate(model, out departmentId); model.id = departmentId; break; case UpdateType.Update: this._departmentService.SectionUpdate(model); break; case UpdateType.Destroy: this._departmentService.SectionDelete(model.id.Value); break; default: break; } } catch (Exception ex) { this.AddModelError(ex); } } if (model.id.HasValue && updateType != UpdateType.Destroy) { model = this._departmentService.SectionGetById(model.id.Value); } return(Json(new[] { model }.ToDataSourceResult(request, ModelState))); }