public ManageUsersAssignationModel ReturnManageUsersAssignationDataModel() { List <RoleModel> roles = new List <RoleModel>(); RoleModel roleModel = new RoleModel() { RoleName = "NewMonafasat_OffersCheckSecretary", RoleNameAr = "NewMonafasat_OffersCheckSecretary" }; roles.Add(roleModel); ManageUsersAssignationModel manageUsersAssignationModel = new ManageUsersAssignationModel() { userId = 102, nationalId = _nationalId, fullName = "test", mobileNumber = "0533286913", AgencyNames = "وزارة الصحة - الديوان العام", AllCommitteeRoles = roles, email = "*****@*****.**", BranchRoles = roles, CommitteeAuditOfferRoles = roles }; return(manageUsersAssignationModel); }
public async Task AddUserToBranchAsyn(BranchUserAssignModel branchUserModel, string agencyCode) { Check.ArgumentNotNull(nameof(branchUserModel), branchUserModel); var user = await _iDMAppService.FindUserProfileByUserNameAsync(branchUserModel.NationalIdString); Enums.UserRole userRole = ((Enums.UserRole)Enum.Parse(typeof(Enums.UserRole), branchUserModel.RoleName)); if (user == null) { ManageUsersAssignationModel emp = await _iDMAppService.GetMonafastatEmployeeDetailById(agencyCode, branchUserModel.NationalIdString, ""); UserProfile userProfile = new UserProfile(emp.userId, emp.nationalId, emp.fullName, emp.mobileNumber, emp.email, await _notificationAppService.GetDefaultSettingByUserType(userRole)); Check.ArgumentNotNull(nameof(userProfile), userProfile); await _genericCommandRepository.CreateAsync(userProfile); branchUserModel.UserId = userProfile.Id; } else { if (!user.NotificationSetting.Any(x => x.UserRoleId == (int)userRole)) { await _branchServiceDomain.CheckUserExist(user.Id, branchUserModel.BranchId, branchUserModel.RoleName); user.AddNotificationSettings(await _notificationAppService.GetDefaultSettingByUserType(userRole)); _genericCommandRepository.Update(user); } branchUserModel.UserId = user.Id; } var branchUser = new BranchUser(branchUserModel.BranchId, branchUserModel.UserId.Value, (int)userRole, branchUserModel.RelatedAgencyCode, branchUserModel.EstimatedValueFrom, branchUserModel.EstimatedValueTo); await _genericCommandRepository.CreateAsync(branchUser); await _genericCommandRepository.SaveAsync(); if (user == null) { if (!string.IsNullOrEmpty(branchUser.UserProfile.Email) || !string.IsNullOrEmpty(branchUser.UserProfile.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(branchUser.UserProfile.Id, branchUser.UserProfile.Email, branchUser.UserProfile.Mobile); } } else { if (!string.IsNullOrEmpty(user.Email) || !string.IsNullOrEmpty(user.Mobile)) { await _notificationAppService.SendNotificationByEmailAndSmsForRolesChanged(user.Id, user.Email, user.Mobile); } } }
public List <ManageUsersAssignationModel> GetUsersAssignation() { List <RoleModel> roles = new List <RoleModel>(); roles.Add(new RoleModel() { RoleNameAr = "NewMonafasat_OffersCheckSecretary", RoleName = "NewMonafasat_OffersCheckSecretary" }); List <ManageUsersAssignationModel> manageUsersAssignationModels = new List <ManageUsersAssignationModel>(); ManageUsersAssignationModel manageUsersAssignationModel = new ManageUsersAssignationModel() { userId = 102, userIdString = "Ahc1Ou5BrJi7B*@@**WUaxDxaQ==", nationalId = _nationalId, nationalIdString = "", roles = roles, AgencyNames = "الديوان العام" }; manageUsersAssignationModels.Add(manageUsersAssignationModel); return(manageUsersAssignationModels); }
public async Task <ActionResult> DetailsAsync(string userIdString) { try { ManageUsersAssignationModel userModel = await _ApiClient.GetAsync <ManageUsersAssignationModel>("ManageUsersAssignation/GetById/" + Util.Decrypt(userIdString), null); if (userModel != null) { EditUserViewModel viewModel = new EditUserViewModel() { AgencyNames = userModel.AgencyNames, agencies = userModel.agencies, UserId = userModel.userId, UserIdString = Util.Encrypt(userModel.userId), UserName = userModel.fullName, MobileNumber = userModel.mobileNumber, Email = userModel.email, NationalId = userModel.nationalId, }; return(View(viewModel)); } return(RedirectToAction(nameof(Index))); } catch (AuthorizationException ex) { throw ex; } catch (BusinessRuleException ex) { AddError(ex.Message); return(RedirectToAction(nameof(Index))); } catch (Exception ex) { _logger.LogError(ex.ToString(), ex); AddError(Resources.TenderResources.ErrorMessages.UnexpectedError); return(RedirectToAction(nameof(Index))); } }