コード例 #1
0
ファイル: HelpController.cs プロジェクト: andreyu/Reports
 public ActionResult CreateServiceRequest(CreateHelpServiceRequestModel model)
 {
     return RedirectToAction(model.IsForQuestion ? "HelpQuestionEdit" : "ServiceRequestEdit",
         new RouteValueDictionary {
                                     {"id", 0},
                                     {"userId", model.UserId}
                                   });
 }
コード例 #2
0
ファイル: HelpBl.cs プロジェクト: andreyu/Reports
        public CreateHelpServiceRequestModel GetCreateHelpServiceRequestModel()
        {
            CreateHelpServiceRequestModel model = new CreateHelpServiceRequestModel();
            User currentUser = UserDao.Load(CurrentUser.Id);

            //if (currentUser == null)
            //    throw new ArgumentException(string.Format("Не могу загрузить пользователя {0} из базы даннных",
            //        CurrentUser.Id));
            IList<IdNameDto> list;
            if ((CurrentUser.UserRole & UserRole.ConsultantPersonnel) > 0)
            {
                var users = UserDao.GetUsersForConsultantBank();
                model.Users = users;
            }
            else
            switch (currentUser.Level)
            {
                case 2:
                case 3:
                    IList<Department> depList =  ManualRoleRecordDao.LoadDepartmentsForUserId(currentUser.Id);
                    if(depList == null || depList.Count() == 0)
                            throw new ArgumentException(string.Format(StrNoManagerDepartments, currentUser.Id));
                    list = UserDao.GetEmployeesForCreateHelpServiceRequest(depList.Select(x => x.Id).Distinct().ToList(), null);
                    model.Users = list;
                    break;
                case 4:
                case 5:
                case 6:
                    if (currentUser.Department == null)
                        throw new ValidationException(string.Format(StrNoDepartmentForUser,currentUser.Id));
                    list = UserDao.GetEmployeesForCreateHelpServiceRequest(new List<int> {currentUser.Department.Id}, null);
                    model.Users = list;
                    break;
            }
            return model;
        }