public async Task <ActionResult> Edit(ThongTinDuTuyenEditViewModel model) { try { var thongTinDuTuyenService = this.Service <IThongTinDuTuyenService>(); var entity = await thongTinDuTuyenService.GetAsync(model.Id); if (entity == null || entity.Active == false) { return(Json(new { success = false, message = Resource.ErrorMessage })); } model.CopyToEntity(entity); entity.Active = true; entity.IdThongTinCaNhan = model.IdThongTinCaNhan; await thongTinDuTuyenService.UpdateAsync(entity); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var result = await new SystemLogController().Create("Sửa", controllerName, entity.Id); return(Json(new { success = true, message = "Sửa thành công!" })); } catch (Exception e) { return(Json(new { success = false, message = Resource.ErrorMessage })); } }
public ActionResult Create() { var thongTinCaNhanService = this.Service <IThongTinCaNhanService>(); var model = new ThongTinDuTuyenEditViewModel(); model.AvailableThongTinCaNhan = thongTinCaNhanService.GetActive().Select(q => new SelectListItem() { Text = q.HoTen + "[CMND: " + q.CMND + "]", Value = q.Id.ToString(), Selected = false, }); return(View(model)); }
public async Task <ActionResult> Edit(int id) { var thongTinDuTuyenService = this.Service <IThongTinDuTuyenService>(); var model = new ThongTinDuTuyenEditViewModel(await thongTinDuTuyenService.GetAsync(id)); if (model == null || model.Active == false) { return(Json(new { success = false, message = Resource.ErrorMessage })); } var thongTinCaNhanService = this.Service <IThongTinCaNhanService>(); var thongTinCaNhan = await thongTinCaNhanService.GetAsync(model.IdThongTinCaNhan); model.HoTen = thongTinCaNhan.HoTen; return(View(model)); }
public async Task <JsonResult> Create(ThongTinDuTuyenEditViewModel model) { try { var thongTinDuTuyenService = this.Service <IThongTinDuTuyenService>(); model.Active = true; var entity = model.ToEntity(); await thongTinDuTuyenService.CreateAsync(entity); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var result = await new SystemLogController().Create("Tạo", controllerName, entity.Id); return(Json(new { success = true, message = "Tạo thành công" })); } catch (Exception e) { return(Json(new { success = false, message = Resource.ErrorMessage })); } }