protected bool ValidateModel(MissionReportsListModel model) { if (model.BeginDate.HasValue && model.EndDate.HasValue && model.BeginDate.Value > model.EndDate.Value) ModelState.AddModelError("BeginDate", "Дата в поле <Период с> не может быть больше даты в поле <по>."); //if (model.IsApproveClick && (model.Documents == null || model.Documents.Count == 0 // || model.Documents.Where(x => x.IsChecked).Count() == 0)) // ModelState.AddModelError(string.Empty, "Не выбрано ни одного приказа для согласования."); return ModelState.IsValid; }
protected void SetMissionReportFilterToSession(MissionReportsListModel model) { MissionOrderFilterModel filterModel = new MissionOrderFilterModel { BeginDate = model.BeginDate, DepartmentId = model.DepartmentId, EndDate = model.EndDate, StatusId = model.StatusId, UserName = model.UserName, Number = model.Number, }; System.Web.HttpContext.Current.Session[SessionMissionReportFilterName] = filterModel; }
protected void SetMissionReportListModelFromSession(MissionReportsListModel model) { MissionOrderFilterModel filterModel = (MissionOrderFilterModel)System.Web.HttpContext.Current.Session[SessionMissionReportFilterName]; if (filterModel != null) { model.StatusId = filterModel.StatusId; model.BeginDate = filterModel.BeginDate; model.EndDate = filterModel.EndDate; model.UserName = filterModel.UserName; model.Number = filterModel.Number; if (AuthenticationService.CurrentUser.UserRole != UserRole.Employee && filterModel.DepartmentId != 0) { Department dep = DepartmentDao.Load(filterModel.DepartmentId); if (dep != null) { model.DepartmentId = filterModel.DepartmentId; model.DepartmentName = dep.Name; } } } }
public ActionResult MissionReportsList(MissionReportsListModel model) { //ModelState.Clear(); bool hasError = !ValidateModel(model); if (!hasError) SetMissionReportFilterToSession(model); RequestBl.SetMissionReportsListModel(model, hasError); //if (model.HasErrors) // ModelState.AddModelError(string.Empty, "При согласовании приказов произошла(и) ошибка(и).Не все приказы были согласованы."); return View(model); }