Пример #1
0
        public ActionResult BranchAdmin()
        {
            List <BranchAdminView> branchesAdminView = BranchAdminHelpers.GetBranchAdminViewList(User);

            ViewBag.CurrentUserId = AppUserHelpers.GetAppUser(User).AppUserId;
            return(View(branchesAdminView));
        }
Пример #2
0
        public ActionResult Index()
        {
            //Show basic web page unless the user is logged in
            if (User.Identity.IsAuthenticated)
            {
                AppUser appUser = AppUserHelpers.GetAppUser(User);

                //If user has not finished setting up user details (i.e. not linked to organisation) then force user to finish details else go to Dashboard
                switch (appUser.EntityStatus)
                {
                case EntityStatusEnum.Active:
                    return(RedirectToAction("Dashboard", "Home"));

                case EntityStatusEnum.AwaitingOrganisationDetails:
                    return(RedirectToAction("OrganisationDetails", "Home"));

                case EntityStatusEnum.OnHold:
                    return(RedirectToAction("Logout", "Account"));

                default:     //other status would have been dealt with so just show home/index view
                    break;
                }
            }

            return(View());
        }
Пример #3
0
        public ActionResult UserAdmin()
        {
            List <UserAdminView> userAdminViewForUser = UserAdminHelpers.GetUserAdminViewListForUser(User);

            ViewBag.CurrentUserId = AppUserHelpers.GetAppUser(User).AppUserId;
            //TempData["OriginalModel"] = userAdminViewForUser;
            return(View(userAdminViewForUser));
        }
Пример #4
0
        public ActionResult Tasks()
        {
            AppUser appUser = AppUserHelpers.GetAppUser(User);

            List <UserTaskView> userTasksForUserView = UserTaskViewHelpers.GetUserTasksForUserView(appUser.AppUserId);

            return(View(userTasksForUserView));
        }
Пример #5
0
        public ActionResult ProcessButton(string buttonName)
        {
            string[] keys = buttonName.Split(':');

            string buttonType    = keys[0];
            string buttonLevel   = keys[1];
            Guid   ofReferenceId = Guid.Empty;
            Guid   byAppUserId   = Guid.Empty;

            Guid.TryParse(keys[2], out ofReferenceId);
            Guid.TryParse(keys[3], out byAppUserId);

            Guid      byReferenceId = Guid.Empty;
            LevelEnum levelEnum     = LevelEnum.User;

            //Set the byReference to be either the user, the user's branch or the user's company depending on level
            switch (buttonLevel)
            {
            case "company":
                levelEnum     = LevelEnum.Company;
                byReferenceId = CompanyHelpers.GetCompanyForUser(byAppUserId).CompanyId;
                break;

            case "branch":
                levelEnum     = LevelEnum.Branch;
                byReferenceId = AppUserHelpers.GetAppUser(byAppUserId).CurrentBranchId;
                break;

            case "user":
                levelEnum     = LevelEnum.User;
                byReferenceId = byAppUserId;
                break;
            }

            switch (buttonType)
            {
            case "block":
                BlockHelpers.CreateBlock(levelEnum, ofReferenceId, byReferenceId, byAppUserId);
                break;

            case "friend":
                FriendHelpers.CreateFriend(levelEnum, ofReferenceId, byReferenceId, byAppUserId);
                break;

            case "group":
                //Need to go to Group screen to select a group or allow adding of a new group
                return(RedirectToAction("Create", "Groups", new { level = levelEnum, ofReferenceId = ofReferenceId, byReferenceId = byReferenceId, appUserid = byAppUserId }));
            }

            return(Json(new { success = true }));
        }
        public ActionResult Edit([Bind(Include = "ListingId,ItemDescription,ItemType,QuantityRequired,QuantityFulfilled,QuantityOutstanding,UoM,RequiredFrom,RequiredTo,AcceptDamagedItems,AcceptOutOfDateItems,CollectionAvailable,ListingStatus,SelectedCampaignId,CampaignName,CampaignStrapLine,CampaignDescription,CampaignStartDateTime,CampaignEndDateTime")] RequirementListingEditView requirementListing)
        {
            if (ModelState.IsValid)
            {
                //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again.
                if (Request.Form["submitbutton"] != null)
                {
                    //Update tables
                    RequirementListingHelpers.UpdateRequirementListingFromRequirementListingEditView(db, requirementListing);

                    return(RedirectToAction("Requirements", "ManageListings"));
                }

                return(RedirectToAction("Edit"));
            }

            //rebuild the missing details before returning to screen to show errors
            RequirementListing listing = RequirementListingHelpers.GetRequirementListing(db, requirementListing.ListingId);

            requirementListing.ListingAppUser       = AppUserHelpers.GetAppUser(db, listing.ListingOriginatorAppUserId);
            requirementListing.ListingBranchDetails = BranchHelpers.GetBranch(db, listing.ListingOriginatorAppUserId);

            //Rebuild campaign details as changing will change ID but no address details, so force the change now:
            if (requirementListing.SelectedCampaignId != null)
            {
                Campaign campaign = CampaignHelpers.GetCampaign(db, requirementListing.SelectedCampaignId.Value);
                requirementListing.CampaignName          = campaign.Name;
                requirementListing.CampaignStrapLine     = campaign.StrapLine;
                requirementListing.CampaignDescription   = campaign.Description;
                requirementListing.CampaignStartDateTime = campaign.CampaignStartDateTime;
                requirementListing.CampaignEndDateTime   = campaign.CampaignEndDateTime;
            }

            ViewBag.CampaignList = ControlHelpers.AllActiveCampaignsForUserListDropDown(AppUserHelpers.GetAppUserIdFromUser(User), requirementListing.SelectedCampaignId);

            return(View(requirementListing));
        }
Пример #7
0
        public ActionResult Edit([Bind(Include = "CampaignId,Name,StrapLine,Description,Image,ImageLocation,Website,CampaignStartDateTime,CampaignEndDateTime,LocationName,LocationAddressLine1,LocationAddressLine2,LocationAddressLine3,LocationAddressTownCity,LocationAddressCounty,LocationAddressPostcode,LocationTelephoneNumber,LocationEmail,LocationContactName,EntityStatus")] CampaignEditView campaign)
        {
            if (ModelState.IsValid)
            {
                //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again.
                if (Request.Form["submitbutton"] != null)
                {
                    //Update tables
                    CampaignHelpers.UpdateCampaignFromCampaignEditView(db, campaign);

                    return(RedirectToAction("Campaigns", "ManageListings"));
                }

                return(RedirectToAction("Edit"));
            }

            //rebuild the missing details before returning to screen to show errors
            Campaign campaignDetails = CampaignHelpers.GetCampaign(db, campaign.CampaignId);

            campaign.CampaignAppUser       = AppUserHelpers.GetAppUser(db, campaignDetails.CampaignOriginatorAppUserId);
            campaign.CampaignBranchDetails = BranchHelpers.GetBranch(db, campaignDetails.CampaignOriginatorBranchId);

            return(View(campaign));
        }
Пример #8
0
        public ActionResult Edit([Bind(Include = "ListingId,ItemDescription,ItemType,QuantityRequired,QuantityFulfilled,QuantityOutstanding,UoM,AvailableFrom,AvailableTo,ItemCondition,DisplayUntilDate,SellByDate,UseByDate,DeliveryAvailable,ListingStatus")] AvailableListingEditView availableListing)
        {
            if (ModelState.IsValid)
            {
                //If the 'Submit' button pressed then update tables, else leave as are so that on reload it takes original values once again.
                if (Request.Form["submitbutton"] != null)
                {
                    //Update tables
                    AvailableListingHelpers.UpdateAvailableListingFromAvailableListingEditView(db, availableListing);

                    return(RedirectToAction("Available", "ManageListings"));
                }

                return(RedirectToAction("Edit"));
            }

            //rebuild the missing details before returning to screen to show errors
            AvailableListing listing = AvailableListingHelpers.GetAvailableListing(db, availableListing.ListingId);

            availableListing.ListingAppUser       = AppUserHelpers.GetAppUser(db, listing.ListingOriginatorAppUserId);
            availableListing.ListingBranchDetails = BranchHelpers.GetBranch(db, listing.ListingOriginatorAppUserId);

            return(View(availableListing));
        }
Пример #9
0
        // GET: Task
        public ActionResult Details(Guid?userTaskId)
        {
            if (userTaskId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            ApplicationDbContext db = new ApplicationDbContext();

            //Get current user for building the Usertaskview of selected record
            AppUser appUser = AppUserHelpers.GetAppUser(db, User);

            //Get UserTaskView of selected UserTask record
            UserTaskView     userTaskView     = null;
            UserTaskFullView userTaskFullView = new UserTaskFullView()
            {
                UserTaskView = userTaskView
            };

            try  //try helps with issues, if no records for example then we are left with null userTaskView instead of error
            {
                userTaskView = UserTaskViewHelpers.GetUserTaskForUserView(db, appUser.AppUserId, userTaskId.Value);

                //Get the requestor appuser details and branch details
                AppUser createdByAppUser = AppUserHelpers.GetAppUser(userTaskView.CreatedBy.AppUserId);
                Branch  createdByAppUserCurrentBranch = BranchHelpers.GetCurrentBranchForUser(db, userTaskView.CreatedBy.AppUserId);

                //If this is a on-hold user then get the current user role
                BranchUser branchUser = null;

                if (userTaskView.AppUserReference != null)
                {
                    branchUser = BranchUserHelpers.GetBranchUser(db, userTaskView.AppUserReference.AppUserId, userTaskView.AppUserReference.CurrentBranchId);
                }

                //Build the view model
                userTaskFullView = new UserTaskFullView();
                userTaskFullView.UserTaskView = userTaskView;
                if (branchUser != null)
                {
                    userTaskFullView.BranchUserUserRole = branchUser.UserRole;
                }
                userTaskFullView.CreatedByAppUser = createdByAppUser;
                userTaskFullView.CreatedByAppUserCurrentBranch = createdByAppUserCurrentBranch;

                if (userTaskView.AppUserReference != null)
                {
                    ViewBag.EntityStatusUserRole = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.AppUserReference.EntityStatus);
                }
                else
                {
                    ViewBag.EntityStatusUserRole = "";
                }

                if (userTaskView.BranchReference != null)
                {
                    ViewBag.EntityStatusBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.UserTaskView.BranchReference.EntityStatus);
                }
                else
                {
                    ViewBag.EntityStatusBranchStatus = "";
                }

                ViewBag.EntityStatusCreatedByUserRole         = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUser.EntityStatus);
                ViewBag.EntityStatusCreatedByUserBranchStatus = EnumHelpers.GetDescription((EntityStatusEnum)userTaskFullView.CreatedByAppUserCurrentBranch.EntityStatus);

                ViewBag.UserTaskUserRole = EnumHelpers.GetDescription((UserRoleEnum)branchUser.UserRole);
            }
            catch { }

            return(View(userTaskFullView));
        }