Exemple #1
0
        public void Should_GovAgencyUpdated()
        {
            GovAgency govAgency = new GovAgency(agencyCode, arabicName, agencyLogoReferenceId, isVro, categoryId, mobileNumber, vrOfficeCode);

            govAgency.GovAgencyUpdated(agencyCode, "", arabicName, categoryId, mobileNumber);
            Assert.Equal(agencyCode, govAgency.AgencyCode);
        }
Exemple #2
0
        public async Task <GovAgency> CreateGovAgencyAsync(GovAgency govAgency)
        {
            await _context.GovAgencies.AddAsync(govAgency);

            //await _context.SaveChangesAsync();
            return(govAgency);
        }
Exemple #3
0
        public void Should_SetPurchaseMethod()
        {
            GovAgency govAgency = new GovAgency(agencyCode, arabicName, agencyLogoReferenceId, isVro, categoryId, mobileNumber, vrOfficeCode);
            string    method    = "1,2";

            govAgency.SetPurchaseMethod(method);
            Assert.Equal(method, govAgency.PurchaseMethods);
        }
Exemple #4
0
        public void Should_SetIsOld()
        {
            GovAgency govAgency = new GovAgency(agencyCode, arabicName, agencyLogoReferenceId, isVro, categoryId, mobileNumber, vrOfficeCode);
            bool      isOld     = true;

            govAgency.SetIsOld(isOld);
            Assert.True(govAgency.IsOldSystem);
        }
Exemple #5
0
        public List <GovAgency> GetGovAgencies()
        {
            GovAgency govAgency = new GovAgency("022001000000", "agency name", null, false, 1, "01222222");

            List <GovAgency> govAgencies = new List <GovAgency>()
            {
                govAgency
            };

            return(govAgencies);
        }
Exemple #6
0
        public async Task <GovAgencyModel> GetAgency()
        {
            string         AgencyCode  = User.UserAgency();
            GovAgencyModel agencyModel = new GovAgencyModel();
            GovAgency      gAgency     = await _blockService.GetAgency(AgencyCode);

            if (gAgency != null)
            {
                agencyModel = new GovAgencyModel()
                {
                    IsOldSystem = gAgency.IsOldSystem
                }
            }
            ;
            return(agencyModel);
        }
Exemple #7
0
        public void Should_Construct_GovAgency()
        {
            GovAgency govAgency = new GovAgency(agencyCode, arabicName, agencyLogoReferenceId, isVro, categoryId, mobileNumber, vrOfficeCode);

            _ = new GovAgency();
            _ = govAgency.NameEnglish;
            _ = govAgency.IsDeleted;
            _ = govAgency.IsPrimary;
            _ = govAgency.IsUGP;
            _ = govAgency.RowVersion;
            _ = govAgency.Branches;
            _ = govAgency.Committees;
            _ = govAgency.Tenders;
            _ = govAgency.VROOfficeCodeRelated;

            govAgency.ShouldNotBeNull();
        }
Exemple #8
0
        public void Should_Construct_GovAgency_Second()
        {
            GovAgency govAgency = new GovAgency(agencyCode, arabicName, agencyLogoReferenceId, false, categoryId, mobileNumber, vrOfficeCode);

            govAgency.ShouldNotBeNull();
        }
Exemple #9
0
        public GovAgency GetGovAgency()
        {
            GovAgency govAgency = new GovAgency("022001000000", "agency name", null, false, 1, "01222222");

            return(govAgency);
        }
        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());
            }
        }
Exemple #11
0
 public GovAgency UpdateGovAgencyAsync(GovAgency govAgency)
 {
     _context.GovAgencies.Update(govAgency);
     //await _context.SaveChangesAsync();
     return(govAgency);
 }