Ejemplo n.º 1
0
        public ActionResult Edit(SystemMenu systemMenu)
        {
            if (systemMenu == null)
            {
                SetFailedNotification("Có lỗi xảy ra. Vui lòng thử lại");
                return(RedirectToAction("Index"));
            }

            if (!ModelState.IsValid)
            {
                foreach (var item in ModelState.Values)
                {
                    foreach (var error in item.Errors)
                    {
                        SetFailedNotification(error.ErrorMessage);
                    }
                }
                if (ItemId > 0)
                {
                    SetPageTitle("Chỉnh sửa menu");
                }
                else
                {
                    SetPageTitle("Tạo mới menu");
                }
                return(View(systemMenu));
            }

            if (_menuRepository.Save(systemMenu))
            {
                SetSuccessNotification("Thêm loại phòng thành công");
            }
            else
            {
                SetFailedNotification("Thêm loại phòng không thành công. Xin thử lại");
            }

            return(RedirectToAction("Index"));
        }