public async Task <JsonResult> Edit(NghiepDoanViewModel model) { var service = this.Service <INghiepDoanService>(); if (!this.ModelState.IsValid) { return(Json(new { success = false, message = "Đã có lỗi xảy ra, vui lòng kiểm tra lại thông tin." })); } try { var entity = model.ToEntity(); await service.UpdateAsync(entity); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var result = await new SystemLogController().Create("Sửa", controllerName, entity.Id); } catch (Exception e) { Console.WriteLine(e); return(Json(new { success = false, message = "Đã có lỗi xảy ra, vui lòng kiểm thử lại." })); } return(Json(new { success = true, message = "Chỉnh sửa thông tin thành công." })); }
public async Task <ActionResult> Create(NghiepDoanViewModel model) { if (!this.ModelState.IsValid) { return(this.View(model)); } var service = this.Service <INghiepDoanService>(); model.Active = true; try { var entity = model.ToEntity(); await service.CreateAsync(entity); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); var result = await new SystemLogController().Create("Tạo", controllerName, entity.Id); } catch (Exception e) { Console.WriteLine(e); } return(this.RedirectToAction("Index")); }