Esempio n. 1
0
 public ActionResult Index(MissionOrderListModel model)
 {
     ModelState.Clear();
     bool hasError = !ValidateModel(model);
     if(!hasError)
         SetMissionOrderFilterToSession(model);
     RequestBl.SetMissionOrderListModel(model, hasError);
     if(model.HasErrors)
         ModelState.AddModelError(string.Empty, "При согласовании приказов произошла(и) ошибка(и).Не все приказы были согласованы.");
     return View(model);
 }
Esempio n. 2
0
 protected void SetMissionOrderListModelFromSession(MissionOrderListModel model)
 {
     MissionOrderFilterModel filterModel = (MissionOrderFilterModel)System.Web.HttpContext.Current.Session[SessionMissionOrderFilterName];
     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;
             }
         }
     }
 }
Esempio n. 3
0
 protected bool ValidateModel(MissionOrderListModel 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;
 }
Esempio n. 4
0
 protected void SetMissionOrderFilterToSession(MissionOrderListModel 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[SessionMissionOrderFilterName] = filterModel;
 }