Example #1
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 #2
0
        public static List <UserTaskView> GetUserTasksForUserView(ApplicationDbContext db, Guid appUserId)
        {
            List <UserTaskView> userTasksForUserView = new List <UserTaskView>();

            List <UserTask> userTasksForUser = UserTaskHelpers.GetUserTasksForUser(db, appUserId);

            foreach (UserTask userTaskForUser in userTasksForUser)
            {
                AppUser appUser = null;
                Branch  branch  = null;

                switch (userTaskForUser.TaskType)
                {
                case TaskTypeEnum.UserOnHold:
                    appUser = AppUserHelpers.GetAppUser(db, userTaskForUser.ReferenceKey);
                    break;

                case TaskTypeEnum.BranchOnHold:
                    branch = BranchHelpers.GetBranch(db, userTaskForUser.ReferenceKey);
                    break;
                }

                UserTaskView userTaskForUserView = new UserTaskView()
                {
                    UserTaskId       = userTaskForUser.UserTaskId,
                    TaskType         = userTaskForUser.TaskType,
                    TaskDescription  = userTaskForUser.TaskDescription,
                    AppUserReference = appUser,
                    BranchReference  = branch,
                    CreatedOn        = userTaskForUser.CreatedOn,
                    CreatedBy        = AppUserHelpers.GetAppUser(db, userTaskForUser.CreatedBy),
                    EntityStatus     = userTaskForUser.EntityStatus
                };

                userTasksForUserView.Add(userTaskForUserView);
            }

            return(userTasksForUserView);
        }