Exemplo n.º 1
0
        public async Task <ActionResult> AssignUsersToCommittees(string committeeIdString, string roleName)
        {
            CommitteeUserModel committeeUserModel = new CommitteeUserModel();

            try
            {
                committeeUserModel.CommitteeId = Util.Decrypt(committeeIdString);
                committeeUserModel.RoleName    = roleName;
                committeeUserModel.Users       = await _ApiClient.GetListAsync <UserLookupModel>("Lookup/GetUsersNotAssignedToCommitteeByRoleName/" + roleName + "/" + committeeUserModel.CommitteeId, null);

                committeeUserModel.CommitteeModel = await _ApiClient.GetAsync <CommitteeTenderModel>("Committee/GetCommitteeTendersAsync/" + Util.Decrypt(committeeIdString).ToString(), null);

                return(View(committeeUserModel));
            }
            catch (AuthorizationException ex)
            {
                throw ex;
            }
            catch (BusinessRuleException ex)
            {
                return(JsonErrorMessage(ex.Message));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                return(JsonErrorMessage(Resources.TenderResources.ErrorMessages.UnexpectedError));
            }
        }
Exemplo n.º 2
0
        public async Task <ActionResult> AssignUsers(CommitteeUserModel committeeUserModel)
        {
            if (!ModelState.IsValid)
            {
                AddError(Resources.TenderResources.ErrorMessages.ModelDataError);
            }
            try
            {
                await _ApiClient.PostAsync("Committee/AssignUsersCommittee", null, committeeUserModel);

                AddMessage(Resources.SharedResources.Messages.DataSaved);
            }
            catch (AuthorizationException ex)
            {
                throw ex;
            }
            catch (BusinessRuleException ex)
            {
                AddError(ex.Message);
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                AddError(Resources.TenderResources.ErrorMessages.UnexpectedError);
            }
            return(RedirectToAction(nameof(AssignUsers), new { committeeIdString = Util.Encrypt(committeeUserModel.CommitteeId) }));
        }
Exemplo n.º 3
0
        public async Task <ActionResult> AssignUsers(string committeeIdString)
        {
            CommitteeUserModel committeeUserModel = new CommitteeUserModel();

            try
            {
                committeeUserModel.CommitteeId    = Util.Decrypt(committeeIdString);
                committeeUserModel.CommitteeModel = await _ApiClient.GetAsync <CommitteeTenderModel>("Committee/GetCommitteeTendersAsync/" + Util.Decrypt(committeeIdString).ToString(), null);

                CommitteeUserSearchCriteriaModel criteria = new CommitteeUserSearchCriteriaModel();
                criteria.CommitteeId     = committeeUserModel.CommitteeId;
                criteria.CommitteeTypeId = committeeUserModel.CommitteeModel.CommitteeTypeId;
                committeeUserModel.CommitteeTypeIdString = Util.Encrypt(criteria.CommitteeTypeId);
                committeeUserModel.Users = await _ApiClient.PostAsync <List <UserLookupModel> >("Committee/GetUsersFilteredbyCommitteeTypeId/", null, criteria);

                return(View(committeeUserModel));
            }
            catch (AuthorizationException ex)
            {
                throw ex;
            }
            catch (BusinessRuleException ex)
            {
                AddError(ex.Message);
                return(RedirectToAction(nameof(AssignUsers), new { committeeIdString = committeeIdString }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString(), ex);
                return(JsonErrorMessage(Resources.TenderResources.ErrorMessages.UnexpectedError));
            }
        }
Exemplo n.º 4
0
        public async Task AddUserAsyn(CommitteeUserModel committeeUserModel, string agencyCode)
        {
            Check.ArgumentNotNull(nameof(committeeUserModel), committeeUserModel);
            var user = await _iDMAppService.FindUserProfileByUserNameAsync(committeeUserModel.UserName);

            List <IDMRolesModel> roles         = _iDMAppService.GetIDMRoles();
            IDMRolesModel        iDMRolesModel = roles.FirstOrDefault(r => r.Name == committeeUserModel.RoleName);

            Enums.UserRole userType    = (Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), iDMRolesModel.Name, true);
            UserProfile    userProfile = new UserProfile();

            if (user == null)
            {
                userProfile = await _iDMAppService.GetUserProfileByEmployeeId(committeeUserModel.UserName, agencyCode, userType);

                Check.ArgumentNotNull(nameof(userProfile), userProfile);
                await _committeeDomainService.CheckUserExist(userProfile.Id, committeeUserModel.CommitteeId);

                await _genericCommandRepository.CreateAsync(userProfile);

                committeeUserModel.UserId = userProfile.Id;
            }
            else
            {
                var defaultSettingsForUserType = await _notificationAppService.GetDefaultSettingByUserType(userType);

                if (user.NotificationSetting.Count(x => x.UserRoleId == (int)userType) < defaultSettingsForUserType.Count)
                {
                    await _committeeDomainService.CheckUserExist(user.Id, committeeUserModel.CommitteeId);

                    user.AddNotificationSettings(defaultSettingsForUserType);
                    _genericCommandRepository.Update(user);
                }
                committeeUserModel.UserId = user.Id;
            }
            CommitteeUser committeeUser = new CommitteeUser(committeeUserModel.CommitteeId, committeeUserModel.UserId, (int)((Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), iDMRolesModel.Name)), committeeUserModel.RelatedAgencyCode);
            await _genericCommandRepository.CreateAsync(committeeUser);

            await _genericCommandRepository.SaveAsync();

            if (user != null)
            {
                if (!string.IsNullOrEmpty(user.Email) || !string.IsNullOrEmpty(user.Mobile))
                {
                    await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(user.Id, user.Email, user.Mobile);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(userProfile.Email) || !string.IsNullOrEmpty(userProfile.Mobile))
                {
                    await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(userProfile.Id, userProfile.Email, userProfile.Mobile);
                }
            }
        }
Exemplo n.º 5
0
 public static async Task AssignUsersCommitteeAsync(CommitteeUserModel committeeUserModel)
 {
     await _userCommittee.PostAsync("Committee/AssignUsersCommittee/", committeeUserModel);
 }
Exemplo n.º 6
0
 public async Task AssignUsersCommittee([FromBody] CommitteeUserModel committeeUserModel)
 {
     committeeUserModel.RelatedAgencyCode = User.UserRelatedAgencyCode();
     await _committeeApplication.AddUserAsyn(committeeUserModel, User.UserAgency());
 }