public async Task <QueryResult <UserProfileModel> > FindListUsers(BlockCommitteeSearchCriteria criteria) { var searchCriteria = new UsersSearchCriteriaModel(); searchCriteria.Email = criteria.Email; searchCriteria.Name = criteria.EmployeeName; searchCriteria.MobileNumber = criteria.PhoneNumber; searchCriteria.PageNumber = criteria.PageNumber; searchCriteria.PageSize = criteria.PageSize; searchCriteria.AgencyId = criteria.AgencyId; searchCriteria.isGovVendor = criteria.isGovVendor; searchCriteria.isSemiGovAgency = criteria.isSemiGovAgency; searchCriteria.AgencyType = (int)criteria.AgencyType; searchCriteria.NationalId = criteria.CommercialRegistrationNo; if (!string.IsNullOrEmpty(searchCriteria.NationalId)) { searchCriteria.NationalIds.Add(searchCriteria.NationalId); } searchCriteria.RoleNames = new List <string> { RoleNames.MonafasatBlockListSecritary, RoleNames.MonafasatBlackListCommittee }; var idmUsers = await _iDMAppService.GetMonafasatUsersForBlockUserList(searchCriteria); var Users = _mapper.Map <QueryResult <UserProfileModel> >(idmUsers); return(Users); }
public async Task <List <UserLookupModel> > GetIDMUsers(BranchUserSearchCriteriaModel criteria) { UsersSearchCriteriaModel userSearchCriteriaModel = new UsersSearchCriteriaModel { AgencyId = criteria.AgencyId, AgencyType = (int)criteria.AgencyType, PageSize = 100, Name = criteria.UserName, Email = criteria.EMail, RoleNames = criteria.RoleNames, RoleName = criteria.RoleName }; var result = await _iDMAppService.GetMonafasatUsers(userSearchCriteriaModel); var employeeList = result.Items; List <UserLookupModel> userLookupModels = new List <UserLookupModel>(); criteria.RoleNames = new List <string> { RoleNames.ApproveTenderAward.ToString(), RoleNames.PurshaseSpecialist.ToString(), RoleNames.EtimadOfficer.ToString(), RoleNames.Auditer.ToString(), RoleNames.DataEntry.ToString(), RoleNames.PrePlanningAuditor.ToString(), RoleNames.PrePlanningCreator.ToString() }; foreach (ManageUsersAssignationModel employee in employeeList) { userLookupModels.Add(new UserLookupModel() { Name = employee.fullName + " - " + employee.nationalId + " - " + employee.email, UserName = employee.nationalId, UserId = employee.userId }); } return(userLookupModels); }
public async Task <List <RoleModel> > GetUserRolesByIdAndCommitteeType(string userName, int CommitteeTypeId) { UsersSearchCriteriaModel userSearchCriteriaModel = new UsersSearchCriteriaModel(); userSearchCriteriaModel = GetUserAgencyTypeAndIdWithFlags(userSearchCriteriaModel); return(await _branchService.GetUserRolesById(userName, userSearchCriteriaModel.AgencyId, CommitteeTypeId, userSearchCriteriaModel)); }
public async Task SendNotifications(int notificationCodeId, string agencyCode, int agencyType, MainNotificationTemplateModel mainView, string UserRole, int committeeId = 0, int branchid = 0) { mainView.CommitteeId = committeeId; mainView.BranchId = branchid; var oldUserNotificationSettings = await _iNotificationQuerie.GetNotificationSettingByUserIdAndUserType(notificationCodeId, branchid, committeeId); if (oldUserNotificationSettings.Count == 0) { return; } UsersSearchCriteriaModel _usersSearchCriteriaModel = new UsersSearchCriteriaModel() { RoleName = UserRole, AgencyId = agencyCode, PageSize = 1000, AgencyType = agencyType }; var idmUsers = await _idmProxy.GetMonafasatUsersByAgencyTypeAndRoleName(_usersSearchCriteriaModel); if (idmUsers == null || !idmUsers.Items.Any()) { return; } var Users = _mapper.Map <QueryResult <EmployeeIntegrationModel> >(idmUsers); List <int> users = Users.Items.Select(x => x.userId).ToList(); var userNotificationSettings = await _iNotificationQuerie.GetNotificationSettingByRoleAndOperationCode(users, notificationCodeId, branchid, committeeId); await SendNotificationForUsers(idmUsers, userNotificationSettings, mainView); }
public async Task <List <UserLookupModel> > GetUsersNotAssignedToCommitteeByRoleName(string roleName, int committeeId) { UsersSearchCriteriaModel criteria = new UsersSearchCriteriaModel(); criteria = GetUserAgencyTypeAndIdWithFlags(criteria); var usersForCommittee = await _iDMAppService.FindUsersByRoleNameAndAgencyCodeNotAssignedToCommitteeAssignAsync(roleName, criteria.AgencyId, committeeId, (AgencyType)criteria.AgencyType); return(usersForCommittee); }
public async Task <List <UserLookupModel> > GetUsersbyCommitteeTypeId(int committeeTypeId, int committeeId) { UsersSearchCriteriaModel userSearchCriteriaModel = new UsersSearchCriteriaModel(); userSearchCriteriaModel = GetUserAgencyTypeAndIdWithFlags(userSearchCriteriaModel); var usersForCommitteeTypeId = await _iDMAppService.GetUsersbyCommitteeTypeId(userSearchCriteriaModel.AgencyId, committeeId, committeeTypeId, "", "", userSearchCriteriaModel.AgencyType); return(usersForCommitteeTypeId); }
public async Task <ManageUsersAssignationModel> GetById(string nationalId) { UsersSearchCriteriaModel userSearchCriteriaModel = new UsersSearchCriteriaModel(); userSearchCriteriaModel = await GetUserAgencyTypeAndIdWithFlags(userSearchCriteriaModel); var employee = await _iDMAppService.GetMonafastatEmployeeDetailById(userSearchCriteriaModel.AgencyId, nationalId, string.Empty, userSearchCriteriaModel.AgencyType); return(employee); }
public async Task ShouldGetMonafasatUsersByAgencyType() { //Arrange UsersSearchCriteriaModel criteria = new UsersSearchCriteriaModel { AgencyType = (int)AgencyType.GovVendor, MobileNumber = "0533286913", Email = "*****@*****.**", Name = "name" }; //Act var result = await _IDMProxy.GetMonafasatUsersByAgencyType(criteria); //Assert Assert.NotNull(result); }
public async Task ShouldGetMonafasatUsersByAgencyTypeAndRoleName() { //Arrange UsersSearchCriteriaModel criteria = new UsersSearchCriteriaModel { RoleName = "NewMonafasat_Admin" }; //Act var result = await _IDMProxy.GetMonafasatUsersByAgencyTypeAndRoleName(criteria); //Assert Assert.NotNull(result); }
public async Task <QueryResult <ManageUsersAssignationModel> > Find(UsersSearchCriteriaModel userSearchCriteriaModel) { if (User.IsInRole(RoleNames.UnitSpecialistLevel1) || User.IsInRole(RoleNames.UnitSpecialistLevel2) || User.IsInRole(RoleNames.UnitManagerUser) || User.IsInRole(RoleNames.UnitBusinessManagement)) { userSearchCriteriaModel.RoleName = RoleNames.OffersCheckSecretary; } userSearchCriteriaModel = await GetUserAgencyTypeAndIdWithFlags(userSearchCriteriaModel); var employeeList = await _iDMAppService.GetMonafasatUsers(userSearchCriteriaModel); return(employeeList); }
private UsersSearchCriteriaModel GetUserAgencyTypeAndIdWithFlags(UsersSearchCriteriaModel userSearchCriteriaModel) { if (User.IsInRole(RoleNames.MonafasatAdmin)) { userSearchCriteriaModel.isGovVendor = User.UserIsGovVendor(); userSearchCriteriaModel.isSemiGovAgency = User.UserIsSemiGovAgency(); userSearchCriteriaModel.AgencyType = userSearchCriteriaModel.isSemiGovAgency ? (int)AgencyType.SemiGovAgency : (userSearchCriteriaModel.isGovVendor ? (int)AgencyType.GovVendor : (int)AgencyType.Agency); userSearchCriteriaModel.AgencyId = User.UserAgency(); } else { userSearchCriteriaModel.AgencyType = (int)AgencyType.None; } return(userSearchCriteriaModel); }
public async Task <List <string> > FindUsersAssignedToBranch(UsersSearchCriteriaModel userSearchCriteriaModel) { var branchesAssignedToUser = await _context.BranchUsers .Where(a => a.IsActive == true && a.BranchId == int.Parse(userSearchCriteriaModel.BranchId)) .WhereIf(!string.IsNullOrEmpty(userSearchCriteriaModel.NationalId), a => a.UserProfile.UserName == userSearchCriteriaModel.NationalId) .WhereIf(!string.IsNullOrEmpty(userSearchCriteriaModel.MobileNumber), a => a.UserProfile.Mobile == userSearchCriteriaModel.MobileNumber.Trim()) .WhereIf(!string.IsNullOrEmpty(userSearchCriteriaModel.Name), a => a.UserProfile.FullName.Contains(userSearchCriteriaModel.Name.Trim())) .WhereIf(!string.IsNullOrEmpty(userSearchCriteriaModel.Email), a => a.UserProfile.Email == userSearchCriteriaModel.Email.Trim()) .Select(c => c.UserProfile.UserName).Distinct().ToListAsync(); if (branchesAssignedToUser.Count == 0) { branchesAssignedToUser.Add("0"); } return(branchesAssignedToUser); }
public async Task ShouldGetUserRolesByIdReturnNull(int committeeTypeId) { UsersSearchCriteriaModel usersSearchCriteriaModel = new UsersSearchCriteriaModel() { PageSize = 100, PageNumber = 1 }; IEnumerable <ManageUsersAssignationModel> manageUsersAssignationModel = new BranchDefaults().GetUsersAssignation(); _moqIDMApp.Setup(m => m.GetMonafasatUsers(It.IsAny <UsersSearchCriteriaModel>())) .Returns(() => { return(Task.FromResult <QueryResult <ManageUsersAssignationModel> >(manageUsersAssignationModel.ToQueryResult().Result)); }); var result = await _sutBranchAppService.GetUserRolesById(new BranchDefaults()._nationalId, new BranchDefaults()._agencyCode, committeeTypeId, usersSearchCriteriaModel); Assert.Null(result); }
private async Task <UsersSearchCriteriaModel> GetUserAgencyTypeAndIdWithFlags(UsersSearchCriteriaModel userSearchCriteriaModel) { if (User.IsInRole(RoleNames.MonafasatAdmin)) { userSearchCriteriaModel.isGovVendor = User.UserIsGovVendor(); userSearchCriteriaModel.isSemiGovAgency = User.UserIsSemiGovAgency(); if (User.UserIsVRO()) { userSearchCriteriaModel.AgencyType = (int)Enums.AgencyType.VRO; } else { userSearchCriteriaModel.AgencyType = userSearchCriteriaModel.isSemiGovAgency ? (int)AgencyType.SemiGovAgency : (userSearchCriteriaModel.isGovVendor ? (int)AgencyType.GovVendor : (int)AgencyType.Agency); } userSearchCriteriaModel.AgencyId = User.UserAgency(); } else {//Account manager + Customer service if (!string.IsNullOrEmpty(userSearchCriteriaModel.AgencyId)) { var agencyCategory = (await _iDMAppService.FindGovAgencyByIdAsync(userSearchCriteriaModel.AgencyId)).CategoryId; userSearchCriteriaModel.AgencyType = agencyCategory.Value;// agencyCategory == (int)IDMUserCategory.GovVendor ? (int)AgencyType.GovVendor : (agencyCategory == (int)IDMUserCategory.PrivateSector ? (int)AgencyType.SemiGovAgency : (int)AgencyType.Agency); } else { userSearchCriteriaModel.AgencyType = (int)AgencyType.None; } } return(userSearchCriteriaModel); }
public async Task <List <RoleModel> > GetUserRolesById(string userName, string agencyCode, int CommitteeTypeId, UsersSearchCriteriaModel searchCriteria) { searchCriteria.PageSize = 100; searchCriteria.NationalIds.Add(userName); var result = await _iDMAppService.GetMonafasatUsers(searchCriteria); var employeeList = result.Items; var employee = employeeList.FirstOrDefault(d => d.nationalId == userName); if (CommitteeTypeId == 0 && employee.roles != null && employee.roles.Any()) { return(employee.roles.Where(r => r != null && (r.RoleName == RoleNames.PurshaseSpecialist.ToString() || r.RoleName == RoleNames.EtimadOfficer.ToString() || r.RoleName == RoleNames.PrePlanningAuditor.ToString() || r.RoleName == RoleNames.PrePlanningCreator.ToString() || r.RoleName == RoleNames.Auditer.ToString() || r.RoleName == RoleNames.ApproveTenderAward.ToString() || r.RoleName == RoleNames.DataEntry.ToString())).Select(d => new RoleModel { RoleId = d.RoleId, RoleName = d.RoleName, RoleNameAr = d.RoleNameAr }).ToList()); } else if (CommitteeTypeId == (int)Enums.CommitteeType.CheckOfferCommittee) { return(employee.roles.Where(r => r != null && (r.RoleName == RoleNames.OffersCheckManager.ToString() || r.RoleName == RoleNames.OffersCheckSecretary.ToString())).Select(r => new RoleModel { RoleId = r.RoleId, RoleName = r.RoleName, RoleNameAr = r.RoleNameAr }).ToList()); } else if (CommitteeTypeId == (int)Enums.CommitteeType.OpenOfferCommittee) { return(employee.roles.Where(r => r != null && (r.RoleName == RoleNames.OffersOppeningManager.ToString() || r.RoleName == RoleNames.OffersOppeningSecretary.ToString())).Select(r => new RoleModel { RoleId = r.RoleId, RoleName = r.RoleName, RoleNameAr = r.RoleNameAr }).ToList()); } else if (CommitteeTypeId == (int)Enums.CommitteeType.TechincalCommittee) { return(employee.roles.Where(r => r != null && r.RoleName == RoleNames.TechnicalCommitteeUser.ToString()).Select(r => new RoleModel { RoleId = r.RoleId, RoleName = r.RoleName, RoleNameAr = r.RoleNameAr }).ToList()); } else if (CommitteeTypeId == (int)Enums.CommitteeType.PreQualificationCommittee) { return(employee.roles.Where(r => r != null && (r.RoleName == RoleNames.PreQualificationCommitteeManager.ToString() || r.RoleName == RoleNames.PreQualificationCommitteeSecretary.ToString())).Select(r => new RoleModel { RoleId = r.RoleId, RoleName = r.RoleName, RoleNameAr = r.RoleNameAr }).ToList()); } else if (CommitteeTypeId == (int)Enums.CommitteeType.PurchaseCommittee) { return(employee.roles.Where(r => r != null && (r.RoleName == RoleNames.OffersPurchaseManager.ToString() || r.RoleName == RoleNames.OffersPurchaseSecretary.ToString())).Select(r => new RoleModel { RoleId = r.RoleId, RoleName = r.RoleName, RoleNameAr = r.RoleNameAr }).ToList()); } else if (CommitteeTypeId == (int)Enums.CommitteeType.VROCommittee) { return(employee.roles.Where(r => r != null && (r.RoleName == RoleNames.OffersOpeningAndCheckManager.ToString() || r.RoleName == RoleNames.OffersOpeningAndCheckSecretary.ToString())).Select(r => new RoleModel { RoleId = r.RoleId, RoleName = r.RoleName, RoleNameAr = r.RoleNameAr }).ToList()); } else { return(null); } }
public async Task SendNotificationForUsersByRoleNameAndAgency(int notificationCodeId, string roleName, MainNotificationTemplateModel mainNotificationTemplateModel, string AgencyCode, int agencyType, List <int> userIds = null) { UsersSearchCriteriaModel _usersSearchCriteriaModel = new UsersSearchCriteriaModel() { RoleName = roleName, AgencyId = AgencyCode, AgencyType = agencyType }; string output = JsonConvert.SerializeObject(mainNotificationTemplateModel); MainNotificationTemplateModel mainView = JsonConvert.DeserializeObject <MainNotificationTemplateModel>(output); List <int> users = new List <int>(); if ((userIds?.Count() ?? 0) == 0) { var idmUsers = await _idmProxy.GetMonafasatUsersByAgencyTypeAndRoleName(_usersSearchCriteriaModel); var Users = _mapper.Map <QueryResult <EmployeeIntegrationModel> >(idmUsers); users = Users.Items.Select(x => x.userId).ToList(); } else { users = userIds; } var userNotificationSettings = await _iNotificationQuerie.GetNotificationSettingByRoleAndOperationCode(users, notificationCodeId); if (userNotificationSettings.Count == 0) { return; } var userNotificationsModel = userNotificationSettings.Select(x => new UserNotificationSettingModel { UserId = x.UserProfileId.Value, Email = x.User.Email, Mobile = x.User.Mobile }).ToList(); var entityKey = TempletKey(mainView.EntityValue, mainView.EntityType); bool IsNullEmailFirstArrgs = string.IsNullOrEmpty(Convert.ToString(mainView.Args.BodyEmailArgs[0])); bool IsNullSmsmFirstArrgs = string.IsNullOrEmpty(Convert.ToString(mainView.Args.SMSArgs[0])); NotificationEmail email; NotificationSMS sms; NotificationPanel panel; foreach (var setting in userNotificationSettings) { if (IsNullEmailFirstArrgs) { mainView.Args.BodyEmailArgs[0] = Convert.ToString(setting.User.FullName); } if (IsNullSmsmFirstArrgs) { mainView.Args.SMSArgs[0] = Convert.ToString(setting.User.FullName); } NotificationDataModel template = await BuildNotificationTemplate(userNotificationSettings.FirstOrDefault().IsArabic, userNotificationSettings.FirstOrDefault().NotificationCodeId, mainView.Args); if (setting.Email) { email = new NotificationEmail(setting.UserProfileId.Value, userNotificationsModel.FirstOrDefault(u => u.UserId == setting.UserProfileId.Value).Email, template.Email.Title, template.Email.Body, setting.Id, mainView.Link, entityKey); await _notifayCommands.AddNotifayWithOutSave(email); } if (setting.Sms) { sms = new NotificationSMS(setting.UserProfileId.Value, userNotificationsModel.FirstOrDefault(u => u.UserId == setting.UserProfileId.Value).Mobile, template.SMS.Body, setting.Id, mainView.Link, entityKey); await _notifayCommands.AddNotifayWithOutSave(sms); } panel = new NotificationPanel(setting.UserProfileId.Value, template.PanelMessage, template.PanelMessage, setting.Id, mainView.Link, mainView.BranchId, mainView.CommitteeId, entityKey); await _notifayCommands.AddNotifayWithOutSave(panel); } if (userNotificationSettings.Count > 0) { await _notifayCommands.SaveChangesAsync(); } }
private async Task SendNotificationForUsers(int notificationCodeId, int branchId, int?committeeId, MainNotificationTemplateModel mainNotificationTemplateModel) { try { string output = JsonConvert.SerializeObject(mainNotificationTemplateModel); MainNotificationTemplateModel mainView = JsonConvert.DeserializeObject <MainNotificationTemplateModel>(output); var oldUserNotificationSettings = await _iNotificationQuerie.GetNotificationSettingByUserIdAndUserType(notificationCodeId, branchId, (committeeId ?? 0)); if (oldUserNotificationSettings.Count == 0) { return; } string UserRole = ((Enums.UserRole)oldUserNotificationSettings[0].UserRoleId).ToString(); var agencyDetails = new GovAgency(); if (branchId != 0) { agencyDetails = await _BranchQuery.GetAgencyCodeByBranchId(branchId); } else if (committeeId != null && committeeId != 0) { agencyDetails = await _CommitteeQuery.FindAgencyCodeByCommitteeId(committeeId); } var agencyCode = agencyDetails != null ? agencyDetails.AgencyCode : ""; var agencyType = agencyDetails != null ? agencyDetails.CategoryId : 0; UsersSearchCriteriaModel _usersSearchCriteriaModel = new UsersSearchCriteriaModel() { RoleName = UserRole, AgencyId = agencyCode, PageSize = 1000, AgencyType = agencyType ?? 0 }; var idmUsers = await _idmProxy.GetMonafasatUsersByAgencyTypeAndRoleName(_usersSearchCriteriaModel); var Users = _mapper.Map <QueryResult <EmployeeIntegrationModel> >(idmUsers); List <int> users = Users.Items.Select(x => x.userId).ToList(); var userNotificationSettings = await _iNotificationQuerie.GetNotificationSettingByRoleAndOperationCode(users, notificationCodeId, branchId, committeeId); var userNotificationsModel = userNotificationSettings.Select(x => new UserNotificationSettingModel { UserId = x.UserProfileId.Value, Email = idmUsers.Items.Where(i => i.userId == x.User.Id).FirstOrDefault().email, Mobile = idmUsers.Items.Where(i => i.userId == x.User.Id).FirstOrDefault().mobileNumber }).ToList(); var entityKey = TempletKey(mainView.EntityValue, mainView.EntityType); bool IsNullEmailFirstArrgs = string.IsNullOrEmpty(Convert.ToString(mainView.Args.BodyEmailArgs[0])); bool IsNullSmsmFirstArrgs = string.IsNullOrEmpty(Convert.ToString(mainView.Args.SMSArgs[0])); NotificationEmail email; NotificationSMS sms; NotificationPanel panel; foreach (var setting in userNotificationSettings) { if (IsNullEmailFirstArrgs) { mainView.Args.BodyEmailArgs[0] = Convert.ToString(setting.User.FullName); } if (IsNullSmsmFirstArrgs) { mainView.Args.SMSArgs[0] = Convert.ToString(setting.User.FullName); } NotificationDataModel template = await BuildNotificationTemplate(userNotificationSettings.FirstOrDefault().IsArabic, userNotificationSettings.FirstOrDefault().NotificationCodeId, mainView.Args); if (setting.Email) { email = new NotificationEmail(setting.UserProfileId.Value, userNotificationsModel.FirstOrDefault(u => u.UserId == setting.UserProfileId.Value).Email, template.Email.Title, template.Email.Body, setting.Id, mainView.Link, entityKey); await _notifayCommands.AddNotifayWithOutSave(email); } if (setting.Sms) { sms = new NotificationSMS(setting.UserProfileId.Value, userNotificationsModel.FirstOrDefault(u => u.UserId == setting.UserProfileId.Value).Mobile, template.SMS.Body, setting.Id, mainView.Link, entityKey); await _notifayCommands.AddNotifayWithOutSave(sms); } panel = new NotificationPanel(setting.UserProfileId.Value, template.PanelMessage, template.PanelMessage, setting.Id, mainView.Link, mainView.BranchId, mainView.CommitteeId, entityKey); await _notifayCommands.AddNotifayWithOutSave(panel); } if (userNotificationSettings.Count > 0) { await _notifayCommands.SaveChangesAsync(); } } catch (Exception ex) { _logger.LogError(ex.ToString()); } }
public async Task <QueryResult <EmployeeIntegrationModel> > GetMonafasatUsersByAgencyType(UsersSearchCriteriaModel searchCriteria) { if (!string.IsNullOrEmpty(searchCriteria.Email)) { searchCriteria.Email = searchCriteria.Email.Trim(); } if (!string.IsNullOrEmpty(searchCriteria.Name)) { searchCriteria.Name = searchCriteria.Name.Trim(); } if (!string.IsNullOrEmpty(searchCriteria.MobileNumber)) { searchCriteria.MobileNumber = searchCriteria.MobileNumber.Trim(); } using (var client = new HttpClient()) { var request = new HttpRequestMessage { RequestUri = new Uri(_rootConfiguration.APIConfiguration.IDM + $"/api/Agency/SearchUsers"), Method = HttpMethod.Post, }; request.Headers.Add("clientid", _rootConfiguration.AuthorityConfiguration.clientid); request.Headers.Add("clientsecret", _rootConfiguration.AuthorityConfiguration.clientsecret); string[] RolesNames = RoleNames.GetMonafasatRoles(); if (searchCriteria.RoleNames == null || searchCriteria.RoleNames.Count == 0) { searchCriteria.RoleNames = new List <string>(); searchCriteria.RoleNames.AddRange(RolesNames); } HttpContent content = new StringContent(JsonConvert.SerializeObject(new { searchCriteria.AgencyId, searchCriteria.AgencyType, searchCriteria.RoleNames, searchCriteria.Name, searchCriteria.MobileNumber, searchCriteria.NationalIds, searchCriteria.Email, searchCriteria.PageSize, searchCriteria.PageNumber, searchCriteria.SortDirection, searchCriteria.AssignedUserIds }), Encoding.UTF8, "application/json"); request.Content = content; request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = await client.SendAsync(request); using (var stream = await result.Content.ReadAsStreamAsync()) { using (var streamReader = new StreamReader(stream)) { using (var reader = new JsonTextReader(streamReader)) { var serializer = new JsonSerializer(); var resultModel = serializer.Deserialize <QueryResult <EmployeeIntegrationModel> >(reader); return(resultModel); } } } } }
public async Task <QueryResult <EmployeeIntegrationModel> > GetMonafasatUsersByAgencyTypeAndRoleName(UsersSearchCriteriaModel searchCriteria) { using (var client = new HttpClient()) { var request = new HttpRequestMessage { RequestUri = new Uri(_rootConfiguration.APIConfiguration.IDM + $"/api/Agency/SearchUsers"), Method = HttpMethod.Post, }; request.Headers.Add("clientid", _rootConfiguration.AuthorityConfiguration.clientid); request.Headers.Add("clientsecret", _rootConfiguration.AuthorityConfiguration.clientsecret); searchCriteria.RoleNames.Add(searchCriteria.RoleName); HttpContent content = new StringContent(JsonConvert.SerializeObject(new { searchCriteria.AgencyId, searchCriteria.AgencyType, searchCriteria.RoleNames, PageSize = 1000 }), Encoding.UTF8, "application/json"); request.Content = content; request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var result = await client.SendAsync(request); using (var stream = await result.Content.ReadAsStreamAsync()) { using (var streamReader = new StreamReader(stream)) { using (var reader = new JsonTextReader(streamReader)) { if (reader == null) { return(new QueryResult <EmployeeIntegrationModel>(new List <EmployeeIntegrationModel>().AsEnumerable(), 0, 1, 10)); } var serializer = new JsonSerializer(); var resultModel = serializer.Deserialize <QueryResult <EmployeeIntegrationModel> >(reader); return(resultModel); } } } } }