Ejemplo n.º 1
0
        public ActionResult Create()
        {
            //prevents users from accessing the page if they are not logged in
            if (userSession.LoggedIn == false)
            {
                return(Content("You are not logged in ! Please Login to create a profile"));
            }

            //fetches the logged in user and checks if they already have a profile
            Account account  = GetAccount();
            var     _account = accountDAO.FetchById(account.accountID);

            if (_account.Profile != null)
            {
                TempData["errorMessage"] = "You already have a BeautySNS Profile!";
                return(RedirectToAction("NewsFeed", "Alert"));
            }

            //checks if the logged in user is admin
            var adminUser = accountPermissionDAO.FetchByEmail(account.email);

            if (adminUser != null)
            {
                TempData["errorMessage"] = "Sorry! Admin users are not permitted to create profiles";
                return(RedirectToAction("SiteActivity", "Alert"));
            }

            CreateViewModel model = new CreateViewModel(jobDAO.FetchAll());

            model.Jobs        = jobDAO.FetchAll(); //fetches all the jobs a user can select from
            model.userSession = userSession.LoggedIn;
            model.adminUser   = false;
            return(View(model));
        }
Ejemplo n.º 2
0
        //returns a list of the jobs
        public ActionResult Index()
        {
            //prevents user from accessing the page if they are not logged in
            if (userSession.LoggedIn == false)
            {
                return(Content("You are not logged in ! Please log in to view this page."));
            }

            //prevents users from accessing the page if they are not admin
            Account account   = GetAccount();
            var     adminUser = accountPermissionDAO.FetchByEmail(account.email);

            if (adminUser == null)
            {
                TempData["errorMessage"] = "This page is only available to admin users!";
                return(RedirectToAction("NewsFeed", "Alert"));
            }

            //returns an index of all the jobs in the system
            var            job   = jobDAO.FetchAll();
            IndexViewModel model = new IndexViewModel(job);

            if (userSession.LoggedIn == true)
            {
                model.userSession = true;
            }

            else if (userSession.LoggedIn == false)
            {
                model.userSession = false;
            }

            model.loggedInAccount   = account;
            model.loggedInAccountID = account.accountID;
            model.permissionType    = adminUser.Permission.name;
            model.adminUser         = true;

            return(View(model));
        }