public ActionResult CreateNew(Unit model) { if (ModelState.IsValid) { try { var check = _unitService.CheckContain(model.Name); if (check) { AlertWarning("Tên đợn vị này đã tồn tại, hãy thử lại với tên khác."); return View(model); } model.CreateDate = DateTime.Now; model.CreateBy = "hadacduong"; _unitService.CreateNew(model); _unitService.CommitChanges(); AlertSuccess("Thêm mới đơn vị thành công."); } catch (Exception ex) { Log(ex); AlertError("Có lỗi xẩy ra trong quá trình xử lý, hãy thử lại."); } return RedirectToAction("Index"); } AlertWarning("Dữ liệu đang sai định dạng, hãy kiểm tra lại dữ liệu."); return View(model); }