Beispiel #1
0
        public static List <Offer> GetAllManageListingFilteredOffers(ApplicationDbContext db, Guid appUserId, bool getHistory)
        {
            AppUser         appUser  = AppUserHelpers.GetAppUser(db, appUserId);
            Branch          branch   = BranchHelpers.GetBranch(db, appUser.CurrentBranchId);
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserId);

            //Create list
            List <Offer> list = new List <Offer>();

            //Now bring in the Selection Level sort
            switch (settings.OffersManageViewInternalSelectionLevel)
            {
            case InternalSearchLevelEnum.User:
                list = GetAllOffersForUser(db, appUserId, getHistory);
                break;

            case InternalSearchLevelEnum.Branch:     //user's current branch to filter
                list = GetAllOffersForBranch(db, branch.BranchId, getHistory);
                break;

            case InternalSearchLevelEnum.Company:     //user's current company to filter
                list = GetAllOffersForCompany(db, branch.CompanyId, getHistory);
                break;

            case InternalSearchLevelEnum.Group:     //user's built group sets to filter ***TO BE DONE***
                break;
            }

            return(list);
        }
        public async Task <CurrentAppUserSettingsDto> GetSettings(CancellationToken cancellationToken)
        {
            var appUser = await GetAuthenticatedAppUserAsync().ConfigureAwait(false);

            var existingSettings = await _appUserService.GetAppUserSettingsAsync(appUser, cancellationToken).ConfigureAwait(false);

            AppUserSettings settings;

            if (existingSettings is null)
            {
                settings = new AppUserSettings
                {
                    UserId = appUser.Id,
                    Theme  = null
                };
                await _appUserService.SaveAppUserSettingsAsync(settings, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                settings = existingSettings;
            }

            return(new CurrentAppUserSettingsDto
            {
                Theme = settings.Theme?.ToString()
            });
        }
Beispiel #3
0
        /// <summary>
        /// Gets the relevant Guid for the level of internal authorisation sent
        /// i.e. If this is a 'User' level of authorisation, then the current user AppUserId is returned.
        /// </summary>
        /// <param name="authorisationLevel"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        public static Guid GetAuthorisationId(InternalSearchLevelEnum authorisationLevel, IPrincipal user)
        {
            Guid id = Guid.Empty;

            AppUser         appUser  = AppUserHelpers.GetAppUser(user);
            Branch          branch   = BranchHelpers.GetBranch(appUser.CurrentBranchId);
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(appUser.AppUserId);

            switch (settings.OrdersDespatchedAuthorisationManageViewLevel)
            {
            case InternalSearchLevelEnum.User:
                id = appUser.AppUserId;
                break;

            case InternalSearchLevelEnum.Branch:
                id = branch.BranchId;
                break;

            case InternalSearchLevelEnum.Company:
                id = branch.CompanyId;
                break;

            case InternalSearchLevelEnum.Group:     //TO BE DONE LSLSLS
                id = appUser.AppUserId;
                break;
            }

            return(id);
        }
Beispiel #4
0
        public static List <AvailableListing> GetAllManageListingFilteredAvailableListings(ApplicationDbContext db, Guid appUserId, bool getHistory)
        {
            AppUser         appUser  = AppUserHelpers.GetAppUser(db, appUserId);
            Branch          branch   = BranchHelpers.GetBranch(db, appUser.CurrentBranchId);
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserId);

            var dateCheck = DateTime.MinValue;

            //Create list within the time frame if setting set
            List <AvailableListing> list = new List <AvailableListing>();

            //Now bring in the Selection Level sort
            switch (settings.AvailableListingManageViewInternalSelectionLevel)
            {
            case InternalSearchLevelEnum.User:
                list = GetAllAvailableListingsForUser(db, appUserId, getHistory);
                break;

            case InternalSearchLevelEnum.Branch:     //user's current branch to filter
                list = GetAllAvailableListingsForBranch(db, branch.BranchId, getHistory);
                break;

            case InternalSearchLevelEnum.Company:     //user's current company to filter
                list = GetAllAvailableListingsForCompany(db, branch.CompanyId, getHistory);
                break;

            case InternalSearchLevelEnum.Group:     //user's built group sets to filter ***TO BE DONE***
                break;
            }

            return(list);
        }
Beispiel #5
0
        public static void DeleteAppUserSettingsForUser(ApplicationDbContext db, Guid appUserId)
        {
            AppUserSettings appUserSettings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserId);

            db.AppUserSettings.Remove(appUserSettings);
            db.SaveChanges();
        }
Beispiel #6
0
        public static AppUserSettings GetAppUserSettingsForUser(Guid appUserId)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            AppUserSettings      appUserSettings = GetAppUserSettingsForUser(db, appUserId);

            db.Dispose();
            return(appUserSettings);
        }
Beispiel #7
0
        public static AppUserSettings CreateAppUserSettingsForNewUser(Guid appUserId, UserRoleEnum userRole)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            AppUserSettings      appUserSettings = CreateAppUserSettingsForNewUser(db, appUserId, userRole);

            db.Dispose();
            return(appUserSettings);
        }
Beispiel #8
0
 public UserNameValidator(IStringLocalizer <CommonValidatorsResource> commonLocalizer
                          , IOptions <AppUserSettings> appUserOptions)
     : base(commonLocalizer["UsernameInvalid"
                            , appUserOptions.Value.UsernameMinLength
                            , appUserOptions.Value.UsernameMaxLength])
 {
     _appUserSettings = appUserOptions.Value;
 }
Beispiel #9
0
        public static AppUserSettings UpdateUserSettingsFromAppUserEditView(AppUserEditView view)
        {
            ApplicationDbContext db       = new ApplicationDbContext();
            AppUserSettings      settings = UpdateUserSettingsFromAppUserEditView(db, view);

            db.Dispose();
            return(settings);
        }
Beispiel #10
0
        public static AppUserSettings GetAppUserSettingsForUser(IPrincipal user)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            AppUserSettings      appUserSettings = GetAppUserSettingsForUser(db, AppUserHelpers.GetAppUserIdFromUser(user));

            db.Dispose();
            return(appUserSettings);
        }
Beispiel #11
0
        public static AppUserSettings GetAppUserSettingsForUser(ApplicationDbContext db, Guid appUserId)
        {
            AppUserSettings settings = (from s in db.AppUserSettings
                                        where s.AppUserId == appUserId
                                        select s).FirstOrDefault();

            return(settings);
        }
Beispiel #12
0
        public static List <AvailableListing> GetAllGeneralInfoFilteredAvailableListings(ApplicationDbContext db, Guid appUserId)
        {
            AppUser         appUser  = AppUserHelpers.GetAppUser(db, appUserId);
            Branch          branch   = BranchHelpers.GetBranch(db, appUser.CurrentBranchId);
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserId);

            var dateCheck           = DateTime.MinValue;
            int settingsMaxDistance = settings.AvailableListingGeneralInfoMaxDistance ?? 0;

            //Create list within the time frame if setting set
            List <AvailableListing> list = (from rl in db.AvailableListings
                                            where ((rl.ListingStatus == ItemRequiredListingStatusEnum.Open || rl.ListingStatus == ItemRequiredListingStatusEnum.Partial) &&
                                                   rl.ListingOriginatorDateTime >= dateCheck)
                                            orderby rl.AvailableTo ?? DateTime.MaxValue
                                            select rl).ToList();

            //Now bring in the Selection Level sort
            switch (settings.AvailableListingGeneralInfoExternalSelectionLevel)
            {
            case ExternalSearchLevelEnum.All:     //do nothing
                break;

            case ExternalSearchLevelEnum.Branch:     //user's current branch to filter
                list = list.Where(l => l.ListingOriginatorBranchId == branch.BranchId).ToList();
                break;

            case ExternalSearchLevelEnum.Company:     //user's current company to filter
                list = list.Where(l => l.ListingOriginatorCompanyId == branch.CompanyId).ToList();
                break;

            case ExternalSearchLevelEnum.Group:     //LSLSLS user's built group sets to filter ***TO BE DONE***
                break;
            }

            //Now sort by distance
            if (settingsMaxDistance > 0)
            {
                List <AvailableListing> removeList = new List <AvailableListing>();

                foreach (AvailableListing listing in list)
                {
                    DistanceHelpers distance      = new DistanceHelpers();
                    int             distanceValue = distance.GetDistance(branch.AddressPostcode, listing.ListingBranchPostcode);

                    if (distanceValue > settingsMaxDistance)
                    {
                        removeList.Add(listing);
                    }
                }

                if (removeList.Count > 0)
                {
                    list.RemoveAll(l => removeList.Contains(l));
                }
            }

            return(list);
        }
Beispiel #13
0
        public static List <Campaign> GetAllGeneralInfoFilteredCampaigns(ApplicationDbContext db, Guid appUserId)
        {
            AppUser         appUser  = AppUserHelpers.GetAppUser(db, appUserId);
            Branch          branch   = BranchHelpers.GetBranch(db, appUser.CurrentBranchId);
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserId);

            var dateCheck           = DateTime.MinValue;
            int settingsMaxDistance = settings.CampaignGeneralInfoMaxDistance ?? 0;

            //Create list within the time frame if setting set
            List <Campaign> list = (from c in db.Campaigns
                                    where (c.EntityStatus == EntityStatusEnum.Active && c.CampaignOriginatorDateTime >= dateCheck)
                                    orderby c.CampaignEndDateTime ?? DateTime.MaxValue
                                    select c).ToList();

            //Now bring in the Selection Level sort
            switch (settings.CampaignGeneralInfoExternalSelectionLevel)
            {
            case ExternalSearchLevelEnum.All:     //do nothing
                break;

            case ExternalSearchLevelEnum.Branch:     //user's current branch to filter
                list = list.Where(l => l.CampaignOriginatorBranchId == branch.BranchId).ToList();
                break;

            case ExternalSearchLevelEnum.Company:     //user's current company to filter
                list = list.Where(l => l.CampaignOriginatorCompanyId == branch.CompanyId).ToList();
                break;

            case ExternalSearchLevelEnum.Group:     //user's built group sets to filter ***TO BE DONE***
                break;
            }

            //Now sort by distance
            if (settingsMaxDistance > 0)
            {
                List <Campaign> removeList = new List <Campaign>();

                foreach (Campaign campaign in list)
                {
                    DistanceHelpers distance      = new DistanceHelpers();
                    int             distanceValue = distance.GetDistance(branch.AddressPostcode, campaign.LocationAddressPostcode);

                    if (distanceValue > settingsMaxDistance)
                    {
                        removeList.Add(campaign);
                    }
                }

                if (removeList.Count > 0)
                {
                    list.RemoveAll(l => removeList.Contains(l));
                }
            }

            return(list);
        }
Beispiel #14
0
        public static List <CampaignGeneralInfoView> GetAllCampaignsGeneralInfoView(ApplicationDbContext db, IPrincipal user)
        {
            List <CampaignGeneralInfoView> allCampaignsGeneralInfoView = new List <CampaignGeneralInfoView>();

            AppUser         appUser       = AppUserHelpers.GetAppUser(db, user);
            AppUserSettings settings      = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUser.AppUserId);
            Branch          currentBranch = BranchHelpers.GetBranch(appUser.CurrentBranchId);

            List <Campaign> allCampaigns = CampaignHelpers.GetAllGeneralInfoFilteredCampaigns(db, appUser.AppUserId);

            foreach (Campaign campaign in allCampaigns)
            {
                bool userBlocked    = false;
                bool branchBlocked  = false;
                bool companyBlocked = false;

                BlockHelpers.GetBlocksForAllTypesForSpecificOfBy(db, campaign.CampaignOriginatorAppUserId, appUser.AppUserId, campaign.CampaignOriginatorBranchId, currentBranch.BranchId, campaign.CampaignOriginatorCompanyId, currentBranch.CompanyId, out userBlocked, out branchBlocked, out companyBlocked);

                bool userMatchedOwner    = false;
                bool branchMatchedOwner  = false;
                bool companyMatchedOwner = false;

                if (currentBranch.CompanyId == campaign.CampaignOriginatorCompanyId)
                {
                    companyMatchedOwner = true;
                }
                if (currentBranch.BranchId == campaign.CampaignOriginatorBranchId)
                {
                    branchMatchedOwner = true;
                }
                if (appUser.AppUserId == campaign.CampaignOriginatorAppUserId)
                {
                    userMatchedOwner = true;
                }

                CampaignGeneralInfoView campaignGeneralInfoView = new CampaignGeneralInfoView()
                {
                    Campaign                = campaign,
                    UserLevelBlock          = userBlocked,
                    BranchLevelBlock        = branchBlocked,
                    CompanyLevelBlock       = companyBlocked,
                    DisplayBlocks           = settings.CampaignGeneralInfoDisplayBlockedListings,
                    CompanyLevelOwner       = companyMatchedOwner,
                    DisplayMyCompanyRecords = settings.CampaignGeneralInfoDisplayMyUserListings,
                    BranchLevelOwner        = branchMatchedOwner,
                    DisplayMyBranchRecords  = settings.CampaignGeneralInfoDisplayMyBranchListings,
                    UserLevelOwner          = userMatchedOwner,
                    DisplayMyRecords        = settings.CampaignGeneralInfoDisplayMyUserListings
                };

                allCampaignsGeneralInfoView.Add(campaignGeneralInfoView);
            }

            return(allCampaignsGeneralInfoView);
        }
Beispiel #15
0
        public static AppUserSettings UpdateUserSettingsFromAppUserEditView(ApplicationDbContext db, AppUserEditView view)
        {
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettings(db, view.AppUserSettingsId);

            settings.CampaignDashboardMaxDistance                        = view.CampaignDashboardMaxDistance;
            settings.CampaignDashboardMaxAge                             = view.CampaignDashboardMaxAge;
            settings.RequiredListingDashboardMaxDistance                 = view.RequiredListingDashboardMaxDistance;
            settings.RequiredListingDashboardMaxAge                      = view.RequiredListingDashboardMaxAge;
            settings.AvailableListingDashboardMaxDistance                = view.AvailableListingDashboardMaxDistance;
            settings.AvailableListingDashboardMaxAge                     = view.AvailableListingDashboardMaxAge;
            settings.CampaignDashboardExternalSelectionLevel             = view.CampaignDashboardExternalSelectionLevel;
            settings.RequiredListingDashboardExternalSelectionLevel      = view.RequiredListingDashboardExternalSelectionLevel;
            settings.AvailableListingDashboardExternalSelectionLevel     = view.AvailableListingDashboardExternalSelectionLevel;
            settings.CampaignGeneralInfoDisplayMyUserListings            = view.CampaignGeneralInfoDisplayMyUserListings;
            settings.CampaignGeneralInfoDisplayMyBranchListings          = view.CampaignGeneralInfoDisplayMyBranchListings;
            settings.CampaignGeneralInfoDisplayMyCompanyListings         = view.CampaignGeneralInfoDisplayMyCompanyListings;
            settings.CampaignGeneralInfoDisplayBlockedListings           = view.CampaignGeneralInfoDisplayBlockedListings;
            settings.CampaignGeneralInfoMaxDistance                      = view.CampaignGeneralInfoMaxDistance;
            settings.RequiredListingGeneralInfoDisplayMyUserListings     = view.RequiredListingGeneralInfoDisplayMyUserListings;
            settings.RequiredListingGeneralInfoDisplayMyBranchListings   = view.RequiredListingGeneralInfoDisplayMyBranchListings;
            settings.RequiredListingGeneralInfoDisplayMyCompanyListings  = view.RequiredListingGeneralInfoDisplayMyCompanyListings;
            settings.RequiredListingGeneralInfoDisplayBlockedListings    = view.RequiredListingGeneralInfoDisplayBlockedListings;
            settings.RequiredListingGeneralInfoMaxDistance               = view.RequiredListingGeneralInfoMaxDistance;
            settings.AvailableListingGeneralInfoDisplayMyUserListings    = view.AvailableListingGeneralInfoDisplayMyUserListings;
            settings.AvailableListingGeneralInfoDisplayMyBranchListings  = view.AvailableListingGeneralInfoDisplayMyBranchListings;
            settings.AvailableListingGeneralInfoDisplayMyCompanyListings = view.AvailableListingGeneralInfoDisplayMyCompanyListings;
            settings.AvailableListingGeneralInfoDisplayBlockedListings   = view.AvailableListingGeneralInfoDisplayBlockedListings;
            settings.AvailableListingGeneralInfoMaxDistance              = view.AvailableListingGeneralInfoMaxDistance;
            settings.CampaignManageViewInternalSelectionLevel            = view.CampaignManageViewInternalSelectionLevel;
            settings.RequiredListingManageViewInternalSelectionLevel     = view.RequiredListingManageViewInternalSelectionLevel;
            settings.AvailableListingManageViewInternalSelectionLevel    = view.AvailableListingManageViewInternalSelectionLevel;
            settings.OffersManageViewInternalSelectionLevel              = view.OffersManageViewInternalSelectionLevel;
            settings.OffersAcceptedAuthorisationManageViewLevel          = view.OffersAcceptedAuthorisationManageViewLevel;
            settings.OffersRejectedAuthorisationManageViewLevel          = view.OffersRejectedAuthorisationManageViewLevel;
            settings.OffersReturnedAuthorisationManageViewLevel          = view.OffersReturnedAuthorisationManageViewLevel;
            settings.OrdersManageViewInternalSelectionLevel              = view.OrdersManageViewInternalSelectionLevel;
            settings.OrdersDespatchedAuthorisationManageViewLevel        = view.OrdersDespatchedAuthorisationManageViewLevel;
            settings.OrdersDeliveredAuthorisationManageViewLevel         = view.OrdersDeliveredAuthorisationManageViewLevel;
            settings.OrdersReceivedAuthorisationManageViewLevel          = view.OrdersReceivedAuthorisationManageViewLevel;
            settings.OrdersCollectedAuthorisationManageViewLevel         = view.OrdersCollectedAuthorisationManageViewLevel;
            settings.OrdersClosedAuthorisationManageViewLevel            = view.OrdersClosedAuthorisationManageViewLevel;
            settings.CampaignGeneralInfoExternalSelectionLevel           = view.CampaignGeneralInfoExternalSelectionLevel;
            settings.RequiredListingGeneralInfoExternalSelectionLevel    = view.RequiredListingGeneralInfoExternalSelectionLevel;
            settings.AvailableListingGeneralInfoExternalSelectionLevel   = view.AvailableListingGeneralInfoExternalSelectionLevel;

            db.Entry(settings).State = EntityState.Modified;
            db.SaveChanges();

            return(settings);
        }
        public void Dispose()
        {
            SecureSettings.Dispose();

            RoamingSettings.Dispose();
            AppUserSettings.Dispose();
            AppSettings.Dispose();
            FileSettings.Dispose();

            EnvVarsSettings.Dispose();
            RegistrySettings.Dispose();
            AppConfigSettings.Dispose();
            AppSwitchSettings.Dispose();
            CliSettings.Dispose();
        }
Beispiel #17
0
        public async Task SaveAppUserSettingsAsync(AppUserSettings settings, CancellationToken cancellationToken = default)
        {
            Guard.Argument(settings, nameof(settings)).NotNull();

            if (await DbContext.AppUserSettings.AnyAsync(s => s.UserId == settings.UserId, cancellationToken).ConfigureAwait(false))
            {
                DbContext.AppUserSettings.Update(settings);
            }
            else
            {
                // ReSharper disable once MethodHasAsyncOverloadWithCancellation
                DbContext.AppUserSettings.Add(settings);
            }

            await DbContext.SaveChangesAsync(cancellationToken).ConfigureAwait(false);
        }
Beispiel #18
0
        public static List <AvailableListingGeneralInfoView> GetAllAvailableListingsGeneralInfoView(ApplicationDbContext db, IPrincipal user)
        {
            List <AvailableListingGeneralInfoView> allAvailableListingsGeneralInfoView = new List <AvailableListingGeneralInfoView>();

            AppUser         appUser       = AppUserHelpers.GetAppUser(db, user);
            AppUserSettings settings      = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUser.AppUserId);
            Branch          currentBranch = BranchHelpers.GetBranch(appUser.CurrentBranchId);

            List <AvailableListing> allAvailableListings = AvailableListingHelpers.GetAllGeneralInfoFilteredAvailableListings(db, appUser.AppUserId);

            foreach (AvailableListing availableListing in allAvailableListings)
            {
                //Find any related offers
                Offer   offer    = OfferHelpers.GetOfferForListingAndUser(db, availableListing.ListingId, appUser.AppUserId);
                decimal offerQty = 0M;
                if (offer != null)
                {
                    offerQty = offer.CurrentOfferQuantity;
                }

                bool userBlocked    = false;
                bool branchBlocked  = false;
                bool companyBlocked = false;

                BlockHelpers.GetBlocksForAllTypesForSpecificOfBy(db, availableListing.ListingOriginatorAppUserId, appUser.AppUserId, availableListing.ListingOriginatorBranchId, currentBranch.BranchId, availableListing.ListingOriginatorCompanyId, currentBranch.CompanyId, out userBlocked, out branchBlocked, out companyBlocked);

                bool userMatchedOwner    = false;
                bool branchMatchedOwner  = false;
                bool companyMatchedOwner = false;

                if (currentBranch.CompanyId == availableListing.ListingOriginatorCompanyId)
                {
                    companyMatchedOwner = true;
                }
                if (currentBranch.BranchId == availableListing.ListingOriginatorBranchId)
                {
                    branchMatchedOwner = true;
                }
                if (appUser.AppUserId == availableListing.ListingOriginatorAppUserId)
                {
                    userMatchedOwner = true;
                }

                Company company = CompanyHelpers.GetCompany(db, availableListing.ListingOriginatorCompanyId);

                AvailableListingGeneralInfoView AvailableListingGeneralInfoView = new AvailableListingGeneralInfoView()
                {
                    AvailableListing        = availableListing,
                    OfferQuantity           = offerQty,
                    AllowBranchTrading      = company.AllowBranchTrading,
                    UserLevelBlock          = userBlocked,
                    BranchLevelBlock        = branchBlocked,
                    CompanyLevelBlock       = companyBlocked,
                    DisplayBlocks           = settings.AvailableListingGeneralInfoDisplayBlockedListings,
                    CompanyLevelOwner       = companyMatchedOwner,
                    DisplayMyCompanyRecords = settings.AvailableListingGeneralInfoDisplayMyUserListings,
                    BranchLevelOwner        = branchMatchedOwner,
                    DisplayMyBranchRecords  = settings.AvailableListingGeneralInfoDisplayMyBranchListings,
                    UserLevelOwner          = userMatchedOwner,
                    DisplayMyRecords        = settings.AvailableListingGeneralInfoDisplayMyUserListings
                };

                allAvailableListingsGeneralInfoView.Add(AvailableListingGeneralInfoView);
            }

            return(allAvailableListingsGeneralInfoView);
        }
Beispiel #19
0
        public static AppUserSettings CreateAppUserSettings(ApplicationDbContext db, Guid appUserId,
                                                            int?campaignDashboardMaxDistance,
                                                            double?campaignDashboardMaxAge,
                                                            int?requiredListingDashboardMaxDistance,
                                                            double?requiredListingDashboardMaxAge,
                                                            int?availableListingDashboardMaxDistance,
                                                            double?availableListingDashboardMaxAge,
                                                            ExternalSearchLevelEnum campaignDashboardExternalSelectionLevel,
                                                            ExternalSearchLevelEnum requiredListingDashboardExternalSelectionLevel,
                                                            ExternalSearchLevelEnum availableListingDashboardExternalSelectionLevel,
                                                            bool campaignGeneralInfoDisplayMyUserListings,
                                                            bool campaignGeneralInfoDisplayMyBranchListings,
                                                            bool campaignGeneralInfoDisplayMyCompanyListings,
                                                            bool campaignGeneralInfoDisplayBlockedListings,
                                                            int?campaignGeneralInfoMaxDistance,
                                                            bool requiredListingGeneralInfoDisplayMyUserListings,
                                                            bool requiredListingGeneralInfoDisplayMyBranchListings,
                                                            bool requiredListingGeneralInfoDisplayMyCompanyListings,
                                                            bool requiredListingGeneralInfoDisplayBlockedListings,
                                                            int?requiredListingGeneralInfoMaxDistance,
                                                            bool availableListingGeneralInfoDisplayMyUserListings,
                                                            bool availableListingGeneralInfoDisplayMyBranchListings,
                                                            bool availableListingGeneralInfoDisplayMyCompanyListings,
                                                            bool availableListingGeneralInfoDisplayBlockedListings,
                                                            int?availableListingGeneralInfoMaxDistance,
                                                            ExternalSearchLevelEnum campaignGeneralInfoExternalSelectionLevel,
                                                            ExternalSearchLevelEnum requiredListingGeneralInfoExternalSelectionLevel,
                                                            ExternalSearchLevelEnum availableListingGeneralInfoExternalSelectionLevel,
                                                            InternalSearchLevelEnum campaignManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum requiredListingManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum availableListingManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum offersManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum offersAcceptedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum offersRejectedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum offersReturnedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum ordersDespatchedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersDeliveredAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersReceivedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersCollectedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersClosedAuthorisationManageViewLevel)
        {
            AppUserSettings appUserSettings = new AppUserSettings()
            {
                AppUserSettingsId                                   = Guid.NewGuid(),
                AppUserId                                           = appUserId,
                CampaignDashboardMaxDistance                        = campaignDashboardMaxDistance,
                CampaignDashboardMaxAge                             = campaignDashboardMaxAge,
                RequiredListingDashboardMaxDistance                 = requiredListingDashboardMaxDistance,
                RequiredListingDashboardMaxAge                      = requiredListingDashboardMaxAge,
                AvailableListingDashboardMaxDistance                = availableListingDashboardMaxDistance,
                AvailableListingDashboardMaxAge                     = availableListingDashboardMaxAge,
                CampaignDashboardExternalSelectionLevel             = campaignDashboardExternalSelectionLevel,
                RequiredListingDashboardExternalSelectionLevel      = requiredListingDashboardExternalSelectionLevel,
                AvailableListingDashboardExternalSelectionLevel     = availableListingDashboardExternalSelectionLevel,
                CampaignGeneralInfoDisplayMyUserListings            = campaignGeneralInfoDisplayMyUserListings,
                CampaignGeneralInfoDisplayMyBranchListings          = campaignGeneralInfoDisplayMyBranchListings,
                CampaignGeneralInfoDisplayMyCompanyListings         = campaignGeneralInfoDisplayMyCompanyListings,
                CampaignGeneralInfoDisplayBlockedListings           = campaignGeneralInfoDisplayBlockedListings,
                CampaignGeneralInfoMaxDistance                      = campaignGeneralInfoMaxDistance,
                RequiredListingGeneralInfoDisplayMyUserListings     = requiredListingGeneralInfoDisplayMyUserListings,
                RequiredListingGeneralInfoDisplayMyBranchListings   = requiredListingGeneralInfoDisplayMyBranchListings,
                RequiredListingGeneralInfoDisplayMyCompanyListings  = requiredListingGeneralInfoDisplayMyCompanyListings,
                RequiredListingGeneralInfoDisplayBlockedListings    = requiredListingGeneralInfoDisplayBlockedListings,
                RequiredListingGeneralInfoMaxDistance               = requiredListingGeneralInfoMaxDistance,
                AvailableListingGeneralInfoDisplayMyUserListings    = availableListingGeneralInfoDisplayMyUserListings,
                AvailableListingGeneralInfoDisplayMyBranchListings  = availableListingGeneralInfoDisplayMyBranchListings,
                AvailableListingGeneralInfoDisplayMyCompanyListings = availableListingGeneralInfoDisplayMyCompanyListings,
                AvailableListingGeneralInfoDisplayBlockedListings   = availableListingGeneralInfoDisplayBlockedListings,
                AvailableListingGeneralInfoMaxDistance              = availableListingGeneralInfoMaxDistance,
                CampaignGeneralInfoExternalSelectionLevel           = campaignGeneralInfoExternalSelectionLevel,
                RequiredListingGeneralInfoExternalSelectionLevel    = requiredListingGeneralInfoExternalSelectionLevel,
                AvailableListingGeneralInfoExternalSelectionLevel   = availableListingGeneralInfoExternalSelectionLevel,
                CampaignManageViewInternalSelectionLevel            = campaignManageViewInternalSelectionLevel,
                RequiredListingManageViewInternalSelectionLevel     = requiredListingManageViewInternalSelectionLevel,
                AvailableListingManageViewInternalSelectionLevel    = availableListingManageViewInternalSelectionLevel,
                OffersManageViewInternalSelectionLevel              = offersManageViewInternalSelectionLevel,
                OffersAcceptedAuthorisationManageViewLevel          = offersAcceptedAuthorisationManageViewLevel,
                OffersRejectedAuthorisationManageViewLevel          = offersRejectedAuthorisationManageViewLevel,
                OffersReturnedAuthorisationManageViewLevel          = offersReturnedAuthorisationManageViewLevel,
                OrdersManageViewInternalSelectionLevel              = ordersManageViewInternalSelectionLevel,
                OrdersDespatchedAuthorisationManageViewLevel        = ordersDespatchedAuthorisationManageViewLevel,
                OrdersDeliveredAuthorisationManageViewLevel         = ordersDeliveredAuthorisationManageViewLevel,
                OrdersReceivedAuthorisationManageViewLevel          = ordersReceivedAuthorisationManageViewLevel,
                OrdersCollectedAuthorisationManageViewLevel         = ordersCollectedAuthorisationManageViewLevel,
                OrdersClosedAuthorisationManageViewLevel            = ordersClosedAuthorisationManageViewLevel
            };

            db.AppUserSettings.Add(appUserSettings);
            db.SaveChanges();

            return(appUserSettings);
        }
Beispiel #20
0
        public static AppUserEditView GetAppUserEditViewForUser(ApplicationDbContext db, AppUser appUserDetails)
        {
            Branch     branch     = BranchHelpers.GetBranch(db, appUserDetails.CurrentBranchId);
            BranchUser branchUser = BranchUserHelpers.GetBranchUser(db, appUserDetails.AppUserId, appUserDetails.CurrentBranchId);

            AppUserSettings appUserSettings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, appUserDetails.AppUserId);

            AppUserEditView view = new AppUserEditView()
            {
                AppUserId                                           = appUserDetails.AppUserId,
                FirstName                                           = appUserDetails.FirstName,
                LastName                                            = appUserDetails.LastName,
                EntityStatus                                        = appUserDetails.EntityStatus,
                PrivacyLevel                                        = appUserDetails.PrivacyLevel,
                SelectedBranchId                                    = appUserDetails.CurrentBranchId,
                UserRole                                            = branchUser.UserRole,
                AppUserSettingsId                                   = appUserSettings.AppUserSettingsId,
                BranchName                                          = branch.BranchName,
                BranchBusinessType                                  = branch.BusinessType,
                BranchAddressLine1                                  = branch.AddressLine1,
                BranchAddressLine2                                  = branch.AddressLine2,
                BranchAddressLine3                                  = branch.AddressLine3,
                BranchAddressTownCity                               = branch.AddressTownCity,
                BranchAddressCounty                                 = branch.AddressCounty,
                BranchAddressPostcode                               = branch.AddressPostcode,
                CampaignDashboardMaxDistance                        = appUserSettings.CampaignDashboardMaxDistance,
                CampaignDashboardMaxAge                             = appUserSettings.CampaignDashboardMaxAge,
                RequiredListingDashboardMaxDistance                 = appUserSettings.RequiredListingDashboardMaxDistance,
                RequiredListingDashboardMaxAge                      = appUserSettings.RequiredListingDashboardMaxAge,
                AvailableListingDashboardMaxDistance                = appUserSettings.AvailableListingDashboardMaxDistance,
                AvailableListingDashboardMaxAge                     = appUserSettings.AvailableListingDashboardMaxAge,
                CampaignDashboardExternalSelectionLevel             = appUserSettings.CampaignDashboardExternalSelectionLevel,
                RequiredListingDashboardExternalSelectionLevel      = appUserSettings.RequiredListingDashboardExternalSelectionLevel,
                AvailableListingDashboardExternalSelectionLevel     = appUserSettings.AvailableListingDashboardExternalSelectionLevel,
                CampaignGeneralInfoDisplayMyUserListings            = appUserSettings.CampaignGeneralInfoDisplayMyUserListings,
                CampaignGeneralInfoDisplayMyBranchListings          = appUserSettings.CampaignGeneralInfoDisplayMyBranchListings,
                CampaignGeneralInfoDisplayMyCompanyListings         = appUserSettings.CampaignGeneralInfoDisplayMyCompanyListings,
                CampaignGeneralInfoDisplayBlockedListings           = appUserSettings.CampaignGeneralInfoDisplayBlockedListings,
                CampaignGeneralInfoMaxDistance                      = appUserSettings.CampaignGeneralInfoMaxDistance,
                RequiredListingGeneralInfoDisplayMyUserListings     = appUserSettings.RequiredListingGeneralInfoDisplayMyUserListings,
                RequiredListingGeneralInfoDisplayMyBranchListings   = appUserSettings.RequiredListingGeneralInfoDisplayMyBranchListings,
                RequiredListingGeneralInfoDisplayMyCompanyListings  = appUserSettings.RequiredListingGeneralInfoDisplayMyCompanyListings,
                RequiredListingGeneralInfoDisplayBlockedListings    = appUserSettings.RequiredListingGeneralInfoDisplayBlockedListings,
                RequiredListingGeneralInfoMaxDistance               = appUserSettings.RequiredListingGeneralInfoMaxDistance,
                AvailableListingGeneralInfoDisplayMyUserListings    = appUserSettings.AvailableListingGeneralInfoDisplayMyUserListings,
                AvailableListingGeneralInfoDisplayMyBranchListings  = appUserSettings.AvailableListingGeneralInfoDisplayMyBranchListings,
                AvailableListingGeneralInfoDisplayMyCompanyListings = appUserSettings.AvailableListingGeneralInfoDisplayMyCompanyListings,
                AvailableListingGeneralInfoDisplayBlockedListings   = appUserSettings.AvailableListingGeneralInfoDisplayBlockedListings,
                AvailableListingGeneralInfoMaxDistance              = appUserSettings.AvailableListingGeneralInfoMaxDistance,
                CampaignManageViewInternalSelectionLevel            = appUserSettings.CampaignManageViewInternalSelectionLevel,
                RequiredListingManageViewInternalSelectionLevel     = appUserSettings.RequiredListingManageViewInternalSelectionLevel,
                AvailableListingManageViewInternalSelectionLevel    = appUserSettings.AvailableListingManageViewInternalSelectionLevel,
                OffersManageViewInternalSelectionLevel              = appUserSettings.OffersManageViewInternalSelectionLevel,
                OffersAcceptedAuthorisationManageViewLevel          = appUserSettings.OffersAcceptedAuthorisationManageViewLevel,
                OffersRejectedAuthorisationManageViewLevel          = appUserSettings.OffersRejectedAuthorisationManageViewLevel,
                OffersReturnedAuthorisationManageViewLevel          = appUserSettings.OffersReturnedAuthorisationManageViewLevel,
                OrdersManageViewInternalSelectionLevel              = appUserSettings.OrdersManageViewInternalSelectionLevel,
                OrdersDespatchedAuthorisationManageViewLevel        = appUserSettings.OrdersDespatchedAuthorisationManageViewLevel,
                OrdersDeliveredAuthorisationManageViewLevel         = appUserSettings.OrdersDeliveredAuthorisationManageViewLevel,
                OrdersCollectedAuthorisationManageViewLevel         = appUserSettings.OrdersCollectedAuthorisationManageViewLevel,
                OrdersClosedAuthorisationManageViewLevel            = appUserSettings.OrdersClosedAuthorisationManageViewLevel,
                CampaignGeneralInfoExternalSelectionLevel           = appUserSettings.CampaignGeneralInfoExternalSelectionLevel,
                RequiredListingGeneralInfoExternalSelectionLevel    = appUserSettings.RequiredListingGeneralInfoExternalSelectionLevel,
                AvailableListingGeneralInfoExternalSelectionLevel   = appUserSettings.AvailableListingGeneralInfoExternalSelectionLevel,
                GroupListViewsForUserOnly                           = GroupViewHelpers.GetGroupEditViewForForUserOnly(db, appUserDetails.AppUserId),
                UserFriendListView                                  = FriendViewHelpers.GetFriendViewByType(db, appUserDetails.AppUserId, LevelEnum.User),
                UserBranchFriendListView                            = FriendViewHelpers.GetFriendViewByType(db, appUserDetails.AppUserId, LevelEnum.Branch),
                UserCompanyFriendListView                           = FriendViewHelpers.GetFriendViewByType(db, appUserDetails.AppUserId, LevelEnum.Company),
                UserBlockListView                                   = BlockViewHelpers.GetBlockViewByType(db, appUserDetails.AppUserId, LevelEnum.User),
                UserBranchBlockListView                             = BlockViewHelpers.GetBlockViewByType(db, appUserDetails.AppUserId, LevelEnum.Branch),
                UserCompanyBlockListView                            = BlockViewHelpers.GetBlockViewByType(db, appUserDetails.AppUserId, LevelEnum.Company)
            };

            return(view);
        }
Beispiel #21
0
        public static AppUserSettings CreateAppUserSettings(Guid appUserId,
                                                            int?campaignDashboardMaxDistance,
                                                            double?campaignDashboardMaxAge,
                                                            int?requiredListingDashboardMaxDistance,
                                                            double?requiredListingDashboardMaxAge,
                                                            int?availableListingDashboardMaxDistance,
                                                            double?availableListingDashboardMaxAge,
                                                            ExternalSearchLevelEnum campaignDashboardExternalSelectionLevel,
                                                            ExternalSearchLevelEnum requiredListingDashboardtExternalSelectionLevel,
                                                            ExternalSearchLevelEnum availableListingDashboardExternalSelectionLevel,
                                                            bool campaignGeneralInfoDisplayMyUserListings,
                                                            bool campaignGeneralInfoDisplayMyBranchListings,
                                                            bool campaignGeneralInfoDisplayMyCompanyListings,
                                                            bool campaignGeneralInfoDisplayBlockedListings,
                                                            int?campaignGeneralInfoMaxDistance,
                                                            bool requiredListingGeneralInfoDisplayMyUserListings,
                                                            bool requiredListingGeneralInfoDisplayMyBranchListings,
                                                            bool requiredListingGeneralInfoDisplayMyCompanyListings,
                                                            bool requiredListingGeneralInfoDisplayBlockedListings,
                                                            int?requiredListingGeneralInfoMaxDistance,
                                                            bool availableListingGeneralInfoDisplayMyUserListings,
                                                            bool availableListingGeneralInfoDisplayMyBranchListings,
                                                            bool availableListingGeneralInfoDisplayMyCompanyListings,
                                                            bool availableListingGeneralInfoDisplayBlockedListings,
                                                            int?availableListingGeneralInfoMaxDistance,
                                                            ExternalSearchLevelEnum campaignGeneralInfoExternalSelectionLevel,
                                                            ExternalSearchLevelEnum requiredListingGeneralInfoExternalSelectionLevel,
                                                            ExternalSearchLevelEnum availableListingGeneralInfoExternalSelectionLevel,
                                                            InternalSearchLevelEnum campaignManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum requiredListingManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum availableListingManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum offersManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum offersAcceptedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum offersRejectedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum offersReturnedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersManageViewInternalSelectionLevel,
                                                            InternalSearchLevelEnum ordersDespatchedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersDeliveredAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersReceivedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersCollectedAuthorisationManageViewLevel,
                                                            InternalSearchLevelEnum ordersClosedAuthorisationManageViewLevel)
        {
            ApplicationDbContext db = new ApplicationDbContext();
            AppUserSettings      appUserSettings = CreateAppUserSettings(db,
                                                                         appUserId,
                                                                         campaignDashboardMaxDistance,
                                                                         campaignDashboardMaxAge,
                                                                         requiredListingDashboardMaxDistance,
                                                                         requiredListingDashboardMaxAge,
                                                                         availableListingDashboardMaxDistance,
                                                                         availableListingDashboardMaxAge,
                                                                         campaignDashboardExternalSelectionLevel,
                                                                         requiredListingDashboardtExternalSelectionLevel,
                                                                         availableListingDashboardExternalSelectionLevel,
                                                                         campaignGeneralInfoDisplayMyUserListings,
                                                                         campaignGeneralInfoDisplayMyBranchListings,
                                                                         campaignGeneralInfoDisplayMyCompanyListings,
                                                                         campaignGeneralInfoDisplayBlockedListings,
                                                                         campaignGeneralInfoMaxDistance,
                                                                         requiredListingGeneralInfoDisplayMyUserListings,
                                                                         requiredListingGeneralInfoDisplayMyBranchListings,
                                                                         requiredListingGeneralInfoDisplayMyCompanyListings,
                                                                         requiredListingGeneralInfoDisplayBlockedListings,
                                                                         requiredListingGeneralInfoMaxDistance,
                                                                         availableListingGeneralInfoDisplayMyUserListings,
                                                                         availableListingGeneralInfoDisplayMyBranchListings,
                                                                         availableListingGeneralInfoDisplayMyCompanyListings,
                                                                         availableListingGeneralInfoDisplayBlockedListings,
                                                                         availableListingGeneralInfoMaxDistance,
                                                                         campaignGeneralInfoExternalSelectionLevel,
                                                                         requiredListingGeneralInfoExternalSelectionLevel,
                                                                         availableListingGeneralInfoExternalSelectionLevel,
                                                                         campaignManageViewInternalSelectionLevel,
                                                                         requiredListingManageViewInternalSelectionLevel,
                                                                         availableListingManageViewInternalSelectionLevel,
                                                                         offersManageViewInternalSelectionLevel,
                                                                         offersAcceptedAuthorisationManageViewLevel,
                                                                         offersRejectedAuthorisationManageViewLevel,
                                                                         offersReturnedAuthorisationManageViewLevel,
                                                                         ordersManageViewInternalSelectionLevel,
                                                                         ordersDespatchedAuthorisationManageViewLevel,
                                                                         ordersDeliveredAuthorisationManageViewLevel,
                                                                         ordersReceivedAuthorisationManageViewLevel,
                                                                         ordersCollectedAuthorisationManageViewLevel,
                                                                         ordersClosedAuthorisationManageViewLevel);

            db.Dispose();
            return(appUserSettings);
        }
Beispiel #22
0
        public static AppUserSettings CreateAppUserSettingsForNewUser(ApplicationDbContext db, Guid appUserId, UserRoleEnum userRole)
        {
            AppUserSettingsUserTemplate template = new AppUserSettingsUserTemplate();

            //Use the USER template as the standard but override for Admin and Managers
            switch (userRole)
            {
            case UserRoleEnum.SuperUser:
            case UserRoleEnum.Admin:
                template = new AppUserSettingsAdminTemplate();
                break;

            case UserRoleEnum.Manager:
                template = new AppUserSettingsManagerTemplate();
                break;
            }

            AppUserSettings appUserSettings = new AppUserSettings()
            {
                AppUserSettingsId                                   = Guid.NewGuid(),
                AppUserId                                           = appUserId,
                CampaignDashboardMaxDistance                        = template.CampaignDashboardMaxDistance,
                CampaignDashboardMaxAge                             = template.CampaignDashboardMaxAge,
                RequiredListingDashboardMaxDistance                 = template.RequiredListingDashboardMaxDistance,
                RequiredListingDashboardMaxAge                      = template.RequiredListingDashboardMaxAge,
                AvailableListingDashboardMaxDistance                = template.AvailableListingDashboardMaxDistance,
                AvailableListingDashboardMaxAge                     = template.AvailableListingDashboardMaxAge,
                CampaignDashboardExternalSelectionLevel             = template.CampaignDashboardExternalSelectionLevel,
                RequiredListingDashboardExternalSelectionLevel      = template.RequiredListingDashboardExternalSelectionLevel,
                AvailableListingDashboardExternalSelectionLevel     = template.AvailableListingDashboardExternalSelectionLevel,
                CampaignGeneralInfoDisplayMyUserListings            = template.CampaignGeneralInfoDisplayMyUserListings,
                CampaignGeneralInfoDisplayMyBranchListings          = template.CampaignGeneralInfoDisplayMyBranchListings,
                CampaignGeneralInfoDisplayMyCompanyListings         = template.CampaignGeneralInfoDisplayMyCompanyListings,
                CampaignGeneralInfoDisplayBlockedListings           = template.CampaignGeneralInfoDisplayBlockedListings,
                CampaignGeneralInfoMaxDistance                      = template.CampaignGeneralInfoMaxDistance,
                RequiredListingGeneralInfoDisplayMyUserListings     = template.RequiredListingGeneralInfoDisplayMyUserListings,
                RequiredListingGeneralInfoDisplayMyBranchListings   = template.RequiredListingGeneralInfoDisplayMyBranchListings,
                RequiredListingGeneralInfoDisplayMyCompanyListings  = template.RequiredListingGeneralInfoDisplayMyCompanyListings,
                RequiredListingGeneralInfoDisplayBlockedListings    = template.RequiredListingGeneralInfoDisplayBlockedListings,
                RequiredListingGeneralInfoMaxDistance               = template.RequiredListingGeneralInfoMaxDistance,
                AvailableListingGeneralInfoDisplayMyUserListings    = template.AvailableListingGeneralInfoDisplayMyUserListings,
                AvailableListingGeneralInfoDisplayMyBranchListings  = template.AvailableListingGeneralInfoDisplayMyBranchListings,
                AvailableListingGeneralInfoDisplayMyCompanyListings = template.AvailableListingGeneralInfoDisplayMyCompanyListings,
                AvailableListingGeneralInfoDisplayBlockedListings   = template.AvailableListingGeneralInfoDisplayBlockedListings,
                AvailableListingGeneralInfoMaxDistance              = template.AvailableListingGeneralInfoMaxDistance,
                CampaignManageViewInternalSelectionLevel            = template.CampaignManageViewInternalSelectionLevel,
                RequiredListingManageViewInternalSelectionLevel     = template.RequiredListingManageViewInternalSelectionLevel,
                AvailableListingManageViewInternalSelectionLevel    = template.AvailableListingManageViewInternalSelectionLevel,
                OffersManageViewInternalSelectionLevel              = template.OffersManageViewInternalSelectionLevel,
                OffersAcceptedAuthorisationManageViewLevel          = template.OffersAcceptedAuthorisationManageViewLevel,
                OffersRejectedAuthorisationManageViewLevel          = template.OffersRejectedAuthorisationManageViewLevel,
                OffersReturnedAuthorisationManageViewLevel          = template.OffersReturnedAuthorisationManageViewLevel,
                OrdersManageViewInternalSelectionLevel              = template.OrdersManageViewInternalSelectionLevel,
                OrdersDespatchedAuthorisationManageViewLevel        = template.OrdersDespatchedAuthorisationManageViewLevel,
                OrdersDeliveredAuthorisationManageViewLevel         = template.OrdersDeliveredAuthorisationManageViewLevel,
                OrdersReceivedAuthorisationManageViewLevel          = template.OrdersReceivedAuthorisationManageViewLevel,
                OrdersCollectedAuthorisationManageViewLevel         = template.OrdersCollectedAuthorisationManageViewLevel,
                OrdersClosedAuthorisationManageViewLevel            = template.OrdersClosedAuthorisationManageViewLevel,
                CampaignGeneralInfoExternalSelectionLevel           = template.CampaignGeneralInfoExternalSelectionLevel,
                RequiredListingGeneralInfoExternalSelectionLevel    = template.RequiredListingGeneralInfoExternalSelectionLevel,
                AvailableListingGeneralInfoExternalSelectionLevel   = template.AvailableListingGeneralInfoExternalSelectionLevel
            };

            db.AppUserSettings.Add(appUserSettings);
            db.SaveChanges();

            return(appUserSettings);
        }
Beispiel #23
0
        public static void SetOrderButtons(ApplicationDbContext db, IPrincipal user, Order order, bool orderOut, out bool?displayDespatchButton, out bool?displayDeliveredButton, out bool?displayReceivedButton, out bool?displayCollectedButton, out bool?displayClosedButton)
        {
            //Get settings for logged in user
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, user);

            //Set the authorisation levels and IDs for button activation on form
            InternalSearchLevelEnum despatchedAuthorisationLevel = settings.OrdersDespatchedAuthorisationManageViewLevel;
            Guid despatchedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OrdersDespatchedAuthorisationManageViewLevel, user);
            InternalSearchLevelEnum deliveredAuthorisationLevel = settings.OrdersDeliveredAuthorisationManageViewLevel;
            Guid deliveredAuthorisationId = DataHelpers.GetAuthorisationId(settings.OrdersDeliveredAuthorisationManageViewLevel, user);
            InternalSearchLevelEnum receivedAuthorisationLevel = settings.OrdersReceivedAuthorisationManageViewLevel;
            Guid receivedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OrdersReceivedAuthorisationManageViewLevel, user);
            InternalSearchLevelEnum collectedAuthorisationLevel = settings.OrdersCollectedAuthorisationManageViewLevel;
            Guid collectedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OrdersCollectedAuthorisationManageViewLevel, user);
            InternalSearchLevelEnum closedAuthorisationLevel = settings.OrdersClosedAuthorisationManageViewLevel;
            Guid closedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OrdersClosedAuthorisationManageViewLevel, user);

            //set buttons
            if (orderOut)
            {
                displayDespatchButton  = true;
                displayDeliveredButton = true;
                displayReceivedButton  = null;
                displayCollectedButton = null;
                displayClosedButton    = true;

                switch (despatchedAuthorisationLevel)
                {
                case InternalSearchLevelEnum.Company:
                    if (order.OrderOriginatorCompanyId != despatchedAuthorisationId && order.OfferOriginatorCompanyId != despatchedAuthorisationId)
                    {
                        displayDespatchButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Branch:
                    if (order.OrderOriginatorBranchId != despatchedAuthorisationId && order.OfferOriginatorBranchId != despatchedAuthorisationId)
                    {
                        displayDespatchButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.User:
                    if (order.OrderOriginatorAppUserId != despatchedAuthorisationId && order.OfferOriginatorAppUserId != despatchedAuthorisationId)
                    {
                        displayDespatchButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Group:       //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }

                switch (deliveredAuthorisationLevel)
                {
                case InternalSearchLevelEnum.Company:
                    if (order.OrderOriginatorCompanyId != deliveredAuthorisationId && order.OfferOriginatorCompanyId != deliveredAuthorisationId)
                    {
                        displayDeliveredButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Branch:
                    if (order.OrderOriginatorBranchId != deliveredAuthorisationId && order.OfferOriginatorBranchId != deliveredAuthorisationId)
                    {
                        displayDespatchButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.User:
                    if (order.OrderOriginatorAppUserId != deliveredAuthorisationId && order.OfferOriginatorAppUserId != deliveredAuthorisationId)
                    {
                        displayDespatchButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Group:       //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }

                switch (closedAuthorisationLevel)
                {
                case InternalSearchLevelEnum.Company:
                    if (order.OrderOriginatorCompanyId != closedAuthorisationId && order.OfferOriginatorCompanyId != closedAuthorisationId)
                    {
                        displayClosedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Branch:
                    if (order.OrderOriginatorBranchId != closedAuthorisationId && order.OfferOriginatorBranchId != closedAuthorisationId)
                    {
                        displayClosedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.User:
                    if (order.OrderOriginatorAppUserId != closedAuthorisationId && order.OfferOriginatorAppUserId != closedAuthorisationId)
                    {
                        displayClosedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Group:       //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
            }
            else
            {
                displayDespatchButton  = null;
                displayDeliveredButton = null;
                displayReceivedButton  = true;
                displayCollectedButton = true;
                displayClosedButton    = true;

                switch (collectedAuthorisationLevel)
                {
                case InternalSearchLevelEnum.Company:
                    if (order.OrderOriginatorCompanyId != collectedAuthorisationId && order.OfferOriginatorCompanyId != collectedAuthorisationId)
                    {
                        displayCollectedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Branch:
                    if (order.OrderOriginatorBranchId != collectedAuthorisationId && order.OfferOriginatorBranchId != collectedAuthorisationId)
                    {
                        displayCollectedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.User:
                    if (order.OrderOriginatorAppUserId != collectedAuthorisationId && order.OfferOriginatorAppUserId != collectedAuthorisationId)
                    {
                        displayCollectedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Group:       //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }

                switch (receivedAuthorisationLevel)
                {
                case InternalSearchLevelEnum.Company:
                    if (order.OrderOriginatorCompanyId != receivedAuthorisationId && order.OfferOriginatorCompanyId != receivedAuthorisationId)
                    {
                        displayReceivedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Branch:
                    if (order.OrderOriginatorBranchId != receivedAuthorisationId && order.OfferOriginatorBranchId != receivedAuthorisationId)
                    {
                        displayReceivedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.User:
                    if (order.OrderOriginatorAppUserId != receivedAuthorisationId && order.OfferOriginatorAppUserId != receivedAuthorisationId)
                    {
                        displayReceivedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Group:       //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }

                switch (closedAuthorisationLevel)
                {
                case InternalSearchLevelEnum.Company:
                    if (order.OrderOriginatorCompanyId != closedAuthorisationId && order.OfferOriginatorCompanyId != closedAuthorisationId)
                    {
                        displayClosedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Branch:
                    if (order.OrderOriginatorBranchId != closedAuthorisationId && order.OfferOriginatorBranchId != closedAuthorisationId)
                    {
                        displayClosedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.User:
                    if (order.OrderOriginatorAppUserId != closedAuthorisationId && order.OfferOriginatorAppUserId != closedAuthorisationId)
                    {
                        displayClosedButton = false;
                    }
                    break;

                case InternalSearchLevelEnum.Group:       //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
            }
        }
Beispiel #24
0
        public static AppUserSettings GetAppUserSettingsForUser(ApplicationDbContext db, IPrincipal user)
        {
            AppUserSettings appUserSettings = GetAppUserSettingsForUser(db, AppUserHelpers.GetAppUserIdFromUser(user));

            return(appUserSettings);
        }
Beispiel #25
0
        public static void SetOrderButtons(ApplicationDbContext db, IPrincipal user, OfferManageView view, out bool?displayAcceptButton, out bool?displayRejectButton, out bool?displayCounterButton, out bool?displayOfferButton)
        {
            //Get settings for logged in user
            AppUserSettings settings = AppUserSettingsHelpers.GetAppUserSettingsForUser(db, user);

            Guid acceptedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OffersAcceptedAuthorisationManageViewLevel, user);
            Guid rejectedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OffersRejectedAuthorisationManageViewLevel, user);
            Guid returnedAuthorisationId = DataHelpers.GetAuthorisationId(settings.OffersReturnedAuthorisationManageViewLevel, user);

            //Set buttons
            displayAcceptButton  = true;
            displayRejectButton  = true;
            displayCounterButton = true;
            displayOfferButton   = true;

            if (view.InhouseOffer)
            {
                switch (view.OfferAppUserSettings.OffersAcceptedAuthorisationManageViewLevel)
                {
                case GeneralEnums.InternalSearchLevelEnum.Company:
                    if (view.OfferDetails.OfferOriginatorCompanyId != acceptedAuthorisationId)
                    {
                        displayAcceptButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Branch:
                    if (view.OfferDetails.OfferOriginatorBranchId != acceptedAuthorisationId)
                    {
                        displayAcceptButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.User:
                    if (view.OfferDetails.OfferOriginatorAppUserId != acceptedAuthorisationId)
                    {
                        displayAcceptButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Group:      //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
                switch (view.OfferAppUserSettings.OffersRejectedAuthorisationManageViewLevel)
                {
                case GeneralEnums.InternalSearchLevelEnum.Company:
                    if (view.OfferDetails.OfferOriginatorCompanyId != rejectedAuthorisationId)
                    {
                        displayRejectButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Branch:
                    if (view.OfferDetails.OfferOriginatorBranchId != rejectedAuthorisationId)
                    {
                        displayRejectButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.User:
                    if (view.OfferDetails.OfferOriginatorAppUserId != rejectedAuthorisationId)
                    {
                        displayRejectButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Group:      //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
                switch (view.OfferAppUserSettings.OffersReturnedAuthorisationManageViewLevel)
                {
                case GeneralEnums.InternalSearchLevelEnum.Company:
                    if (view.OfferDetails.OfferOriginatorCompanyId != returnedAuthorisationId)
                    {
                        displayOfferButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Branch:
                    if (view.OfferDetails.OfferOriginatorBranchId != returnedAuthorisationId)
                    {
                        displayOfferButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.User:
                    if (view.OfferDetails.OfferOriginatorAppUserId != returnedAuthorisationId)
                    {
                        displayOfferButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Group:      //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
            }
            else
            {
                switch (view.ListingAppUserSettings.OffersAcceptedAuthorisationManageViewLevel)
                {
                case GeneralEnums.InternalSearchLevelEnum.Company:
                    if (view.OfferDetails.ListingOriginatorCompanyId != acceptedAuthorisationId)
                    {
                        displayAcceptButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Branch:
                    if (view.OfferDetails.ListingOriginatorBranchId != acceptedAuthorisationId)
                    {
                        displayAcceptButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.User:
                    if (view.OfferDetails.ListingOriginatorAppUserId != acceptedAuthorisationId)
                    {
                        displayAcceptButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Group:      //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
                switch (view.ListingAppUserSettings.OffersRejectedAuthorisationManageViewLevel)
                {
                case GeneralEnums.InternalSearchLevelEnum.Company:
                    if (view.OfferDetails.ListingOriginatorCompanyId != rejectedAuthorisationId)
                    {
                        displayRejectButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Branch:
                    if (view.OfferDetails.ListingOriginatorBranchId != rejectedAuthorisationId)
                    {
                        displayRejectButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.User:
                    if (view.OfferDetails.ListingOriginatorAppUserId != rejectedAuthorisationId)
                    {
                        displayRejectButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Group:      //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
                switch (view.ListingAppUserSettings.OffersReturnedAuthorisationManageViewLevel)
                {
                case GeneralEnums.InternalSearchLevelEnum.Company:
                    if (view.OfferDetails.ListingOriginatorCompanyId != returnedAuthorisationId)
                    {
                        displayCounterButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Branch:
                    if (view.OfferDetails.ListingOriginatorBranchId != returnedAuthorisationId)
                    {
                        displayCounterButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.User:
                    if (view.OfferDetails.ListingOriginatorAppUserId != returnedAuthorisationId)
                    {
                        displayCounterButton = false;
                    }
                    break;

                case GeneralEnums.InternalSearchLevelEnum.Group:      //LSLSLS  TO BE DONE WHEN GROUPS ADDED
                    break;
                }
            }
        }
Beispiel #26
0
 public EmailValidator(IOptions <AppUserSettings> appUserSettings
                       , IStringLocalizer <CommonValidatorsResource> commonLocalizer)
     : base(commonLocalizer["EmailInvalid"])
 {
     _appUserSettings = appUserSettings.Value;
 }