Example #1
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);
        }
Example #2
0
        //public static SelectList AllActiveCampaignsForUserListDropDown(Guid appUserId)
        //{
        //    return new SelectList(CampaignHelpers.GetAllCampaignsForUser(appUserId), "CampaignId", "Name");
        //}

        public static SelectList AllActiveCampaignsForUserListDropDown(Guid appUserId, Guid?selectedCampaignId)
        {
            if (selectedCampaignId == null)
            {
                return(new SelectList(CampaignHelpers.GetAllCampaignsForUser(appUserId, false), "CampaignId", "Name", "Select campaign"));
            }
            else
            {
                return(new SelectList(CampaignHelpers.GetAllCampaignsForUser(appUserId, false), "CampaignId", "Name", selectedCampaignId));
            }
        }
Example #3
0
        public static DashboardView GetDashboardViewLogin(ApplicationDbContext db, IPrincipal user)
        {
            AppUser appUser = AppUserHelpers.GetAppUser(db, user);

            //initialise the view
            DashboardView dashboardView = new DashboardView();

            //get the campaigns and listings for this user
            List <Campaign> campaignsForUser = CampaignHelpers.GetAllCampaignsForUser(db, appUser.AppUserId, false);

            dashboardView.CampaignList = campaignsForUser;

            List <Campaign> campaignsDashboardList = CampaignHelpers.GetAllDashboardFilteredCampaigns(db, appUser.AppUserId);

            dashboardView.CampaignDashboardList = campaignsDashboardList;

            List <RequirementListing> requirementListingsForUser = RequirementListingHelpers.GetAllRequirementListingsForUser(db, appUser.AppUserId, false);

            dashboardView.RequirementListingList = requirementListingsForUser;

            List <RequirementListing> requirementListingDashboardList = RequirementListingHelpers.GetAllDashboardFilteredRequirementListings(db, appUser.AppUserId);

            dashboardView.RequirementListingDashboardList = requirementListingDashboardList;

            List <AvailableListing> availableListingsForUser = AvailableListingHelpers.GetAllAvailableListingsForUser(db, appUser.AppUserId, false);

            dashboardView.AvailableListingList = availableListingsForUser;

            List <AvailableListing> availableListingDashboardList = AvailableListingHelpers.GetAllDashboardFilteredAvailableListings(db, appUser.AppUserId);

            dashboardView.AvailableListingDashboardList = availableListingDashboardList;

            List <Offer> offersForUser = OfferHelpers.GetAllOffersForUser(db, appUser.AppUserId, false);

            dashboardView.OfferList = offersForUser;

            List <Order> ordersForUser = OrderHelpers.GetAllOrdersForUser(db, appUser.AppUserId, false);

            dashboardView.OrderList = ordersForUser;

            //get listings for admin areas if this user is not a 'User' - i.e. is Manager, Admin etc.
            if (user.Identity.GetCurrentUserRole() != "User")
            {
                List <UserTask> tasksForUser = UserTaskHelpers.GetUserTasksForUser(db, appUser.AppUserId);
                //LSLSLS get list of 'actions' once written

                dashboardView.UserTaskList = tasksForUser;
            }

            return(dashboardView);
        }
Example #4
0
        public static DashboardView GetDashboardView(ApplicationDbContext db)
        {
            //initialise the view
            DashboardView dashboardView = new DashboardView();

            //get the campaigns and listings for this user
            List <Campaign> campaigns = CampaignHelpers.GetAllCampaigns(db);

            dashboardView.CampaignList = campaigns;

            List <RequirementListing> requirementListings = RequirementListingHelpers.GetAllRequirementListings(db);

            dashboardView.RequirementListingList = requirementListings;

            return(dashboardView);
        }
Example #5
0
        public static List <CampaignManageView> GetAllCampaignsManageViewForUserBranch(ApplicationDbContext db, IPrincipal user)
        {
            List <CampaignManageView> allCampaignsManageView = new List <CampaignManageView>();

            BranchUser      branchUser = BranchUserHelpers.GetBranchUserCurrentForUser(db, user);
            List <Campaign> allCampaignsForBranchUser = CampaignHelpers.GetAllCampaignsForBranchUser(db, branchUser);

            foreach (Campaign campaignForBranchUser in allCampaignsForBranchUser)
            {
                CampaignManageView campaignManageView = new CampaignManageView()
                {
                    Campaign = campaignForBranchUser
                };

                allCampaignsManageView.Add(campaignManageView);
            }

            return(allCampaignsManageView);
        }
Example #6
0
        public static List <CampaignManageView> GetAllCampaignsManageView(ApplicationDbContext db, IPrincipal user, bool getHistory)
        {
            List <CampaignManageView> allCampaignsManageView = new List <CampaignManageView>();

            AppUser         appUser             = AppUserHelpers.GetAppUser(db, user);
            List <Campaign> allCampaignsForUser = CampaignHelpers.GetAllManageListingFilteredCampaigns(db, appUser.AppUserId, getHistory);

            foreach (Campaign campaignForBranchUser in allCampaignsForUser)
            {
                CampaignManageView campaignManageView = new CampaignManageView()
                {
                    Campaign = campaignForBranchUser
                };

                allCampaignsManageView.Add(campaignManageView);
            }

            return(allCampaignsManageView);
        }
Example #7
0
        public static CampaignEditView GetCampaignEditView(ApplicationDbContext db, Guid campaignId, IPrincipal user)
        {
            Campaign campaignDetails = CampaignHelpers.GetCampaign(db, campaignId);
            AppUser  campaignAppUser = AppUserHelpers.GetAppUser(db, campaignDetails.CampaignOriginatorAppUserId);
            Branch   campaignBranch  = BranchHelpers.GetBranch(db, campaignDetails.CampaignOriginatorBranchId);
            Company  campaignCompany = CompanyHelpers.GetCompany(db, campaignDetails.CampaignOriginatorCompanyId);

            ViewButtons buttons = ViewButtonsHelpers.GetAvailableButtonsForSingleView(db, campaignAppUser, campaignBranch, campaignCompany, user);

            CampaignEditView view = new CampaignEditView()
            {
                CampaignId                 = campaignDetails.CampaignId,
                Name                       = campaignDetails.Name,
                StrapLine                  = campaignDetails.StrapLine,
                Description                = campaignDetails.Description,
                Image                      = campaignDetails.Image,
                ImageLocation              = campaignDetails.ImageLocation,
                Website                    = campaignDetails.Website,
                CampaignStartDateTime      = campaignDetails.CampaignStartDateTime,
                CampaignEndDateTime        = campaignDetails.CampaignEndDateTime,
                LocationName               = campaignDetails.LocationName,
                LocationAddressLine1       = campaignDetails.LocationAddressLine1,
                LocationAddressLine2       = campaignDetails.LocationAddressLine2,
                LocationAddressLine3       = campaignDetails.LocationAddressLine3,
                LocationAddressTownCity    = campaignDetails.LocationAddressTownCity,
                LocationAddressCounty      = campaignDetails.LocationAddressCounty,
                LocationAddressPostcode    = campaignDetails.LocationAddressPostcode,
                LocationTelephoneNumber    = campaignDetails.LocationTelephoneNumber,
                LocationEmail              = campaignDetails.LocationEmail,
                LocationContactName        = campaignDetails.LocationContactName,
                EntityStatus               = campaignDetails.EntityStatus,
                CampaignOriginatorDateTime = campaignDetails.CampaignOriginatorDateTime,
                CampaignAppUser            = campaignAppUser,
                CampaignBranchDetails      = campaignBranch,
                CampaignCompanyDetails     = campaignCompany,
                Buttons                    = buttons
            };

            return(view);
        }
Example #8
0
        public static RequirementListingEditView GetRequirementListingEditView(ApplicationDbContext db, Guid listingId, IPrincipal user)
        {
            RequirementListing requirementListing = RequirementListingHelpers.GetRequirementListing(db, listingId);
            AppUser            listingAppUser     = AppUserHelpers.GetAppUser(db, requirementListing.ListingOriginatorAppUserId);
            Branch             listingBranch      = BranchHelpers.GetBranch(db, requirementListing.ListingOriginatorBranchId);
            Company            listingCompany     = CompanyHelpers.GetCompany(db, requirementListing.ListingOriginatorCompanyId);
            Campaign           listingCampaign    = null;
            Guid     campaignId            = Guid.Empty;
            string   campaignName          = "";
            string   campaignStrapline     = "";
            string   campaignDescription   = "";
            DateTime?campaignStartDateTime = null;
            DateTime?campaignEndDateTime   = null;

            ViewButtons buttons = ViewButtonsHelpers.GetAvailableButtonsForSingleView(db, listingAppUser, listingBranch, listingCompany, user);

            if (requirementListing.CampaignId != null)
            {
                if (requirementListing.CampaignId.Value != Guid.Empty)
                {
                    listingCampaign       = CampaignHelpers.GetCampaign(db, requirementListing.CampaignId.Value);
                    campaignId            = listingCampaign.CampaignId;
                    campaignName          = listingCampaign.Name;
                    campaignStrapline     = listingCampaign.StrapLine;
                    campaignDescription   = listingCampaign.Description;
                    campaignStartDateTime = listingCampaign.CampaignStartDateTime;
                    campaignEndDateTime   = listingCampaign.CampaignEndDateTime;
                }
            }

            RequirementListingEditView view = new RequirementListingEditView()
            {
                ListingId           = requirementListing.ListingId,
                ItemDescription     = requirementListing.ItemDescription,
                ItemCategory        = requirementListing.ItemCategory,
                ItemType            = requirementListing.ItemType,
                QuantityRequired    = requirementListing.QuantityRequired,
                QuantityFulfilled   = requirementListing.QuantityFulfilled,
                QuantityOutstanding = requirementListing.QuantityOutstanding,
                UoM                       = requirementListing.UoM,
                RequiredFrom              = requirementListing.RequiredFrom,
                RequiredTo                = requirementListing.RequiredTo,
                AcceptDamagedItems        = requirementListing.AcceptDamagedItems,
                AcceptOutOfDateItems      = requirementListing.AcceptOutOfDateItems,
                CollectionAvailable       = requirementListing.CollectionAvailable,
                ListingStatus             = requirementListing.ListingStatus,
                ListingOriginatorDateTime = requirementListing.ListingOriginatorDateTime,
                ListingAppUser            = listingAppUser,
                ListingBranchDetails      = listingBranch,
                ListingCompanyDetails     = listingCompany,
                SelectedCampaignId        = campaignId,
                CampaignName              = campaignName,
                CampaignStrapLine         = campaignStrapline,
                CampaignDescription       = campaignStrapline,
                CampaignStartDateTime     = campaignStartDateTime,
                CampaignEndDateTime       = campaignEndDateTime,
                Buttons                   = buttons
            };

            return(view);
        }