예제 #1
0
        public static List <Branch> GetBranchesForUserForAdminView(ApplicationDbContext db, Guid appUserId)
        {
            AppUser    currentAppUser    = AppUserHelpers.GetAppUser(db, appUserId);
            Branch     currentBranch     = BranchHelpers.GetBranch(db, currentAppUser.CurrentBranchId);
            BranchUser currentBranchUser = BranchUserHelpers.GetBranchUser(db, appUserId, currentAppUser.CurrentBranchId, currentBranch.CompanyId);

            List <BranchUser> branchUserForUser = BranchUserHelpers.GetBranchUsersForUserWithRole(db, appUserId, currentBranchUser.UserRole);

            List <Branch> branchesForUser = new List <Branch>();

            foreach (BranchUser branchUser in branchUserForUser)
            {
                branchesForUser.Add(BranchHelpers.GetBranch(db, branchUser.BranchId));
            }

            List <Branch> branchesForUserDistinct = branchesForUser.Distinct().ToList();

            return(branchesForUserDistinct);
        }
예제 #2
0
        public static ViewButtons GetAvailableButtonsForSingleView(ApplicationDbContext db, AppUser appUser, Branch branch, Company company, IPrincipal user)
        {
            //Build initial list
            ViewButtons buttons = new ViewButtons()
            {
                CompanyBlockButton      = false,
                CompanyAddFriendButton  = false,
                CompanyAddToGroupButton = false,
                BranchBlockButton       = false,
                BranchAddFriendButton   = false,
                BranchAddToGroupButton  = false,
                UserBlockButton         = false,
                UserAddFriendButton     = false,
                UserAddToGroupButton    = false
            };

            //First: check this is not our listing
            AppUser currentUser = AppUserHelpers.GetAppUser(db, user);

            if (currentUser.AppUserId == appUser.AppUserId)
            {
                return(buttons);
            }

            //Second: check the branch is not our branch, else return current button settings
            if (currentUser.CurrentBranchId == branch.BranchId)
            {
                return(buttons);
            }

            //Third: check if the Company allows interbranch dealing, if not and company level are the same return current button settings
            Branch currentUserBranch = BranchHelpers.GetBranch(db, currentUser.CurrentBranchId);

            if (!company.AllowBranchTrading && currentUserBranch.CompanyId == company.CompanyId)
            {
                return(buttons);
            }

            //Now validate for button status depending on type of user for this branch user combo
            BranchUser branchUser = BranchUserHelpers.GetBranchUser(db, appUser.AppUserId, branch.BranchId, company.CompanyId);

            switch (branchUser.UserRole)
            {
            //Note - must be in this order as there are override checks the lower down the ranking/role you go
            case UserRoleEnum.SuperUser:
            case UserRoleEnum.Admin:
                buttons = SetCompanyButtons(db, buttons, company.CompanyId, currentUserBranch.CompanyId);
                buttons = SetBranchButtons(db, buttons, branch.BranchId, currentUser.CurrentBranchId);
                buttons = SetUserButtons(db, buttons, appUser.AppUserId, currentUser.AppUserId);
                break;

            case UserRoleEnum.Manager:
                buttons = SetBranchButtons(db, buttons, branch.BranchId, currentUser.CurrentBranchId);
                buttons = SetUserButtons(db, buttons, appUser.AppUserId, currentUser.AppUserId);
                break;

            case UserRoleEnum.User:
                buttons = SetUserButtons(db, buttons, appUser.AppUserId, currentUser.AppUserId);
                break;
            }

            return(buttons);
        }
예제 #3
0
        public static List <BranchAdminView> GetBranchAdminViewList(ApplicationDbContext db, IPrincipal user)
        {
            List <BranchAdminView> branchAdminViewList = new List <BranchAdminView>();

            //Get the AppUser of this User
            AppUser appUser = AppUserHelpers.GetAppUser(db, user);

            //Get the list of branches this User is linked to
            List <Branch> branchesForAppUser = BranchHelpers.GetBranchesForUserForAdminView(db, appUser.AppUserId);

            //Build a list of all users that are linked to this company
            List <AppUser> allUsersForCompany = AppUserHelpers.GetAppUsersForCompany(branchesForAppUser[0].CompanyId);

            foreach (Branch branch in branchesForAppUser)
            {
                //Build list of company users to add to this branchView
                List <BranchAdminViewCompanyUser> branchAdminCompanyUsers = new List <BranchAdminViewCompanyUser>();

                //Build a list of all users for this branch
                List <AppUser> allUsersForThisBranch = (from bu in db.BranchUsers
                                                        join au in db.AppUsers on bu.UserId equals au.AppUserId
                                                        where (bu.BranchId == branch.BranchId && bu.EntityStatus == EntityStatusEnum.Active)
                                                        select au).Distinct().ToList();

                //Add all company users to the 'RelatedCompanyUsers' and set the flag to true if the user appears in the branch list
                List <BranchAdminViewCompanyUser> relatedCompanyUsers = new List <BranchAdminViewCompanyUser>();
                foreach (AppUser userForCompany in allUsersForCompany)
                {
                    UserRoleEnum?role = null;

                    //If the user appears in branchlist then set the 'linked' flag
                    bool    found     = false;
                    AppUser foundUser = allUsersForThisBranch.FirstOrDefault(x => x.AppUserId == userForCompany.AppUserId);
                    if (foundUser != null)
                    {
                        //get role from branchuser for this userForCompany/branch
                        BranchUser branchUserForCompany = BranchUserHelpers.GetBranchUser(db, userForCompany.AppUserId, branch.BranchId, branch.CompanyId);
                        role  = branchUserForCompany.UserRole;
                        found = true;
                    }

                    BranchAdminViewCompanyUser branchAdminCompanyUser = new BranchAdminViewCompanyUser()
                    {
                        AppUserId          = userForCompany.AppUserId,
                        CurrentBranchId    = userForCompany.CurrentBranchId,
                        FirstName          = userForCompany.FirstName,
                        LastName           = userForCompany.LastName,
                        UserRole           = role,
                        EntityStatus       = userForCompany.EntityStatus,
                        LinkedToThisBranch = found
                    };

                    branchAdminCompanyUsers.Add(branchAdminCompanyUser);
                }


                //Add this list of users (as UserAdminRelatedBranchView(s)) to the model
                BranchAdminView branchAdminView = new BranchAdminView()
                {
                    BranchId            = branch.BranchId,
                    CompanyId           = branch.CompanyId,
                    BranchName          = branch.BranchName,
                    BusinessType        = branch.BusinessType,
                    AddressLine1        = branch.AddressLine1,
                    AddressLine2        = branch.AddressLine2,
                    AddressLine3        = branch.AddressLine3,
                    AddressTownCity     = branch.AddressTownCity,
                    AddressCounty       = branch.AddressCounty,
                    AddressPostcode     = branch.AddressPostcode,
                    TelephoneNumber     = branch.TelephoneNumber,
                    Email               = branch.Email,
                    ContactName         = branch.ContactName,
                    PrivacyLevel        = branch.PrivacyLevel,
                    EntityStatus        = branch.EntityStatus,
                    CompanyUserListId   = Guid.NewGuid(), //used to identify the following list in the view (can't use BranchId as that is used for a different block in the table)
                    RelatedCompanyUsers = branchAdminCompanyUsers
                };

                branchAdminViewList.Add(branchAdminView);
            }

            return(branchAdminViewList);
        }
예제 #4
0
        public static bool UpdateBranchesFromBranchAdminView(ApplicationDbContext db, List <BranchAdminView> branchesAdminView, IPrincipal user)
        {
            //Get logged in user details for Task creation (if required)
            AppUser loggedInUser = AppUserHelpers.GetAppUser(db, user);

            try
            {
                foreach (BranchAdminView branchAdminVeiw in branchesAdminView)
                {
                    //Get original branch record so that we can compare previous and current entity status'
                    Branch           branch = BranchHelpers.GetBranch(db, branchAdminVeiw.BranchId);
                    EntityStatusEnum previousEntityStatus = branch.EntityStatus;

                    //Update branch
                    branch = BranchHelpers.UpdateBranch(db,
                                                        branchAdminVeiw.BranchId,
                                                        branchAdminVeiw.CompanyId,
                                                        branchAdminVeiw.BusinessType,
                                                        branchAdminVeiw.BranchName,
                                                        branchAdminVeiw.AddressLine1,
                                                        branchAdminVeiw.AddressLine2,
                                                        branchAdminVeiw.AddressLine3,
                                                        branchAdminVeiw.AddressTownCity,
                                                        branchAdminVeiw.AddressCounty,
                                                        branchAdminVeiw.AddressPostcode,
                                                        branchAdminVeiw.TelephoneNumber,
                                                        branchAdminVeiw.Email,
                                                        branchAdminVeiw.ContactName,
                                                        branchAdminVeiw.PrivacyLevel,
                                                        branchAdminVeiw.EntityStatus);

                    //if change of status from on-hold - anything then look for outstanding task and set to closed
                    if (branchAdminVeiw.EntityStatus != EntityStatusEnum.OnHold && previousEntityStatus == EntityStatusEnum.OnHold)
                    {
                        List <UserTask> activeTasksForThisBranch = UserTaskHelpers.GetUserTasksForBranch(db, branch.BranchId);

                        foreach (UserTask activeTaskForThisBranch in activeTasksForThisBranch)
                        {
                            UserTaskHelpers.UpdateEntityStatus(activeTaskForThisBranch.UserTaskId, EntityStatusEnum.Closed);
                        }
                    }

                    //If change of status to on-hold then create a Task
                    if (branchAdminVeiw.EntityStatus == EntityStatusEnum.OnHold && previousEntityStatus != EntityStatusEnum.OnHold)
                    {
                        UserTaskHelpers.CreateUserTask(TaskTypeEnum.BranchOnHold, "New branch on hold, awaiting administrator activation", branch.BranchId, loggedInUser.AppUserId, EntityStatusEnum.Active);
                    }

                    //Update Users link with Branch
                    foreach (BranchAdminViewCompanyUser companyUser in branchAdminVeiw.RelatedCompanyUsers)
                    {
                        //Try to find the user
                        BranchUser branchUser = BranchUserHelpers.GetBranchUser(db, companyUser.AppUserId, branchAdminVeiw.BranchId, branchAdminVeiw.CompanyId);

                        //Now check if user is checked in list then ensure it is on branchUser, else remove if it is on branchUser
                        if (companyUser.LinkedToThisBranch)
                        {
                            //if company user linked but not on BranchUser, add to BranchUser
                            if (branchUser == null)
                            {
                                BranchUserHelpers.CreateBranchUser(db, companyUser.AppUserId, branchAdminVeiw.BranchId, branchAdminVeiw.CompanyId, UserRoleEnum.User, EntityStatusEnum.Active);
                            }
                            //if company user linked but not ACTIVE on BranchUser
                            else if (branchUser.EntityStatus != EntityStatusEnum.Active)
                            {
                                BranchUserHelpers.UpdateBranchUserStatus(db, branchUser, EntityStatusEnum.Active, companyUser.AppUserId);
                            }
                        }
                        else
                        {
                            //if company user not linked but is on BranchUser, remove from BranchUser by setting status to Inactive
                            if (branchUser != null)
                            {
                                BranchUserHelpers.UpdateBranchUserStatus(db, branchUser, EntityStatusEnum.Inactive, companyUser.AppUserId);
                            }
                        }
                    }
                }
                return(true);
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                return(false);
            }
        }
예제 #5
0
        public static List <UserAdminView> GetUserAdminViewListForUser(ApplicationDbContext db, IPrincipal user)
        {
            List <UserAdminView> userAdminViewListForUser       = new List <UserAdminView>();
            List <UserAdminRelatedBranchesView> relatedBranches = new List <UserAdminRelatedBranchesView>();

            AppUser    appUser    = AppUserHelpers.GetAppUser(db, user);
            BranchUser branchUser = BranchUserHelpers.GetBranchUser(db, appUser.AppUserId, appUser.CurrentBranchId);


            switch (user.Identity.GetCurrentUserRole())
            {
            case "SuperUser":
            case "Admin":     //Get all users for the company of this user
                var branchUsersForCompany = (from b in db.BranchUsers
                                             join a in db.AppUsers on b.UserId equals a.AppUserId
                                             where (b.CompanyId == branchUser.CompanyId && b.EntityStatus == EntityStatusEnum.Active)
                                             select new { AppUserId = b.UserId, BranchId = b.BranchId, BranchUserId = b.BranchUserId, CurrentBranchId = a.CurrentBranchId, UserRole = b.UserRole }).Distinct().ToList();

                foreach (var branchUserForCompany in branchUsersForCompany)
                {
                    UserAdminRelatedBranchesView relatedBranch = new UserAdminRelatedBranchesView();
                    relatedBranch.AppUserId    = branchUserForCompany.AppUserId;
                    relatedBranch.BranchId     = branchUserForCompany.BranchId;
                    relatedBranch.BranchUserId = branchUserForCompany.BranchUserId;
                    relatedBranch.UserRole     = branchUserForCompany.UserRole;

                    //relatedBranch.BranchUserDetails = BranchUserHelpers.GetBranchUser(db, branchUserForCompany.BranchUserId);
                    Branch branchDetails = BranchHelpers.GetBranch(db, branchUserForCompany.BranchId);

                    relatedBranch.BranchName      = branchDetails.BranchName;
                    relatedBranch.AddressLine1    = branchDetails.AddressLine1;
                    relatedBranch.AddressTownCity = branchDetails.AddressTownCity;
                    relatedBranch.AddressPostcode = branchDetails.AddressPostcode;

                    if (branchUserForCompany.BranchId == branchUserForCompany.CurrentBranchId)
                    {
                        relatedBranch.CurrentBranch = true;
                    }
                    else
                    {
                        relatedBranch.CurrentBranch = false;
                    }

                    relatedBranches.Add(relatedBranch);
                }

                List <AppUser> appUsersForCompany = (from b in branchUsersForCompany
                                                     join a in db.AppUsers on b.AppUserId equals a.AppUserId
                                                     select a).Distinct().ToList();

                foreach (AppUser appUserForCompany in appUsersForCompany)
                {
                    UserAdminView userAdminView = new UserAdminView();
                    userAdminView.AppUserId           = appUserForCompany.AppUserId;
                    userAdminView.FirstName           = appUserForCompany.FirstName;
                    userAdminView.LastName            = appUserForCompany.LastName;
                    userAdminView.AppUserEntityStatus = appUserForCompany.EntityStatus;
                    userAdminView.CurrentBranchId     = appUserForCompany.CurrentBranchId;
                    userAdminView.LoginEmail          = appUserForCompany.LoginEmail;
                    userAdminView.RelatedBranches     = (from rb in relatedBranches
                                                         where (rb.AppUserId == appUserForCompany.AppUserId)
                                                         select rb).ToList();

                    userAdminViewListForUser.Add(userAdminView);
                }
                break;

            case "Manager":     //Get all users for the branches of this user as manager (manager)
                var branchList = (from bu in db.BranchUsers
                                  where (bu.UserId == appUser.AppUserId && bu.UserRole == UserRoleEnum.Manager)
                                  select new { BranchId = bu.BranchId }).Distinct().ToList();

                //var branchUsersForBranch = (from b in db.BranchUsers
                //                            join a in db.AppUsers on b.UserId equals a.AppUserId
                //                            join c in branchList on b.BranchId equals c.BranchId
                //                            where (b.BranchId == appUser.CurrentBranchId && b.EntityStatus == EntityStatusEnum.Active)
                //                            select new { AppUserId = b.UserId, BranchId = b.BranchId, BranchUserId = b.BranchUserId, CurrentBranchId = a.CurrentBranchId, UserRole = b.UserRole }).Distinct().ToList();

                var branchUsersForBranchList = (from bl in branchList
                                                join bu in db.BranchUsers on bl.BranchId equals bu.BranchId
                                                join au in db.AppUsers on bu.UserId equals au.AppUserId
                                                where (bu.CompanyId == branchUser.CompanyId && bu.EntityStatus == EntityStatusEnum.Active)
                                                select new { AppUserId = bu.UserId, BranchId = bu.BranchId, BranchUserId = bu.BranchUserId, CurrentBranchId = au.CurrentBranchId, UserRole = bu.UserRole }).Distinct().ToList();

                foreach (var branchUserForBranch in branchUsersForBranchList)
                {
                    UserAdminRelatedBranchesView relatedBranch = new UserAdminRelatedBranchesView();
                    relatedBranch.AppUserId    = branchUserForBranch.AppUserId;
                    relatedBranch.BranchId     = branchUserForBranch.BranchId;
                    relatedBranch.BranchUserId = branchUserForBranch.BranchUserId;
                    relatedBranch.UserRole     = branchUserForBranch.UserRole;
                    //relatedBranch.BranchUserDetails = BranchUserHelpers.GetBranchUser(db, branchUserForBranch.BranchUserId);
                    Branch branchDetails = BranchHelpers.GetBranch(db, branchUserForBranch.BranchId);

                    relatedBranch.BranchName      = branchDetails.BranchName;
                    relatedBranch.AddressLine1    = branchDetails.AddressLine1;
                    relatedBranch.AddressTownCity = branchDetails.AddressTownCity;
                    relatedBranch.AddressPostcode = branchDetails.AddressPostcode;

                    if (branchUserForBranch.BranchId == branchUserForBranch.CurrentBranchId)
                    {
                        relatedBranch.CurrentBranch = true;
                    }
                    else
                    {
                        relatedBranch.CurrentBranch = false;
                    }

                    relatedBranches.Add(relatedBranch);
                }

                List <AppUser> appUsersForBranchList = (from b in branchUsersForBranchList
                                                        join a in db.AppUsers on b.AppUserId equals a.AppUserId
                                                        select a).Distinct().ToList();

                foreach (AppUser appUserForBranch in appUsersForBranchList)
                {
                    UserAdminView userAdminView = new UserAdminView();
                    userAdminView.AppUserId           = appUserForBranch.AppUserId;
                    userAdminView.FirstName           = appUserForBranch.FirstName;
                    userAdminView.LastName            = appUserForBranch.LastName;
                    userAdminView.AppUserEntityStatus = appUserForBranch.EntityStatus;
                    userAdminView.CurrentBranchId     = appUserForBranch.CurrentBranchId;
                    userAdminView.LoginEmail          = appUserForBranch.LoginEmail;
                    userAdminView.RelatedBranches     = (from rb in relatedBranches
                                                         where (rb.AppUserId == appUserForBranch.AppUserId)
                                                         select rb).ToList();

                    userAdminViewListForUser.Add(userAdminView);
                }

                break;
            }

            return(userAdminViewListForUser);
        }
예제 #6
0
        public static Order CreateOrder(ApplicationDbContext db, IPrincipal user, Offer offer)
        {
            BranchUser branchUser = BranchUserHelpers.GetBranchUserCurrentForUser(db, user);

            //depending on 'branch trading' check to see if last counter is related to this user, if not then use the last counter details (if counter details exist)
            if (offer.LastCounterOfferOriginatorAppUserId != null)
            {
                Company company = CompanyHelpers.GetCompany(db, branchUser.CompanyId);

                if (company.AllowBranchTrading)
                {
                    if (branchUser.BranchId != offer.LastCounterOfferOriginatorBranchId)
                    {
                        branchUser = BranchUserHelpers.GetBranchUser(db, offer.LastCounterOfferOriginatorAppUserId.Value, offer.LastCounterOfferOriginatorBranchId.Value, offer.LastCounterOfferOriginatorCompanyId.Value);
                    }
                }
                else
                {
                    if (branchUser.CompanyId != offer.LastCounterOfferOriginatorCompanyId)
                    {
                        branchUser = BranchUserHelpers.GetBranchUser(db, offer.LastCounterOfferOriginatorAppUserId.Value, offer.LastCounterOfferOriginatorBranchId.Value, offer.LastCounterOfferOriginatorCompanyId.Value);
                    }
                }
            }

            decimal orderQty = offer.CurrentOfferQuantity;

            if (offer.CurrentOfferQuantity == 0 && offer.CounterOfferQuantity != 0)
            {
                orderQty = offer.CounterOfferQuantity.Value;
            }

            Order order = new Order()
            {
                OrderId                    = Guid.NewGuid(),
                ListingType                = offer.ListingType,
                OrderQuanity               = orderQty,
                OrderStatus                = OrderStatusEnum.New,
                OrderCreationDateTime      = DateTime.Now,
                OrderOriginatorAppUserId   = branchUser.UserId,
                OrderOriginatorBranchId    = branchUser.BranchId,
                OrderOriginatorCompanyId   = branchUser.CompanyId,
                OrderOriginatorDateTime    = DateTime.Now,
                OfferId                    = offer.OfferId,
                OfferOriginatorAppUserId   = offer.OfferOriginatorAppUserId,
                OfferOriginatorBranchId    = offer.OfferOriginatorBranchId,
                OfferOriginatorCompanyId   = offer.OfferOriginatorCompanyId,
                ListingId                  = offer.ListingId,
                ListingOriginatorAppUserId = offer.ListingOriginatorAppUserId,
                ListingOriginatorBranchId  = offer.ListingOriginatorBranchId,
                ListingOriginatorCompanyId = offer.ListingOriginatorCompanyId
            };

            db.Orders.Add(order);

            //Update the quantities on listing

            switch (offer.ListingType)
            {
            case ListingTypeEnum.Available:
                AvailableListingHelpers.UpdateQuantitiesFromOrder(db, offer);
                break;

            case ListingTypeEnum.Requirement:
                RequirementListingHelpers.UpdateQuantitiesFromOrder(db, offer);
                break;
            }

            db.SaveChanges();

            return(order);
        }
예제 #7
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);
        }