Beispiel #1
0
        public ActionResult UserProfileHomepage(int id = 0)
        {
            var account            = accountDAL.FetchByID(id);
            DetailsViewModel model = new DetailsViewModel(account.Profile);

            return(View(model));
        }
Beispiel #2
0
        //fetches the details of a user
        public ActionResult AccountDetails(int id = 0)
        {
            Account account = accountDAL.FetchByID(id);

            if (account == null)
            {
                TempData["errorMessage"] = "Sorry. This user does not exist !";
                return(RedirectToAction("AdminDashboard"));
            }

            PlugPool.ViewModels.Accounts.DetailsViewModel model = new PlugPool.ViewModels.Accounts.DetailsViewModel(account);
            return(View(model));
        }
Beispiel #3
0
        public ActionResult Create(CreateViewModel model, int id = 0)
        {
            Account account     = GetAccount();
            Account userAccount = accountDAL.FetchByID(id);

            if (ModelState.IsValid)
            {
                Note _note = new Note
                {
                    accountID   = userAccount.accountID,
                    leftBy      = account.accountID,
                    note        = model.note,
                    dateCreated = DateTime.Now
                };
                noteDAL.Create(_note);
                _email.SendProfileDeclinedEmail(userAccount.email, userAccount.email, model.note);
                return(RedirectToAction("AdminDashboard", "Admin"));
            }
            return(View(model));
        }
Beispiel #4
0
        public ActionResult Login(LoginViewModel model, string email, string password)
        {
            if (ModelState.IsValid)
            {
                email    = model.email;
                password = model.password.Encrypt(email);
                Account account = accountDAL.FetchByEmail(email);

                if (account != null)
                {
                    if (account.password == password)
                    {
                        if (account.isVerified == true)
                        {
                            var adminUser = accountPermissionDAL.FetchByEmail(account.email);
                            if (adminUser != null)
                            {
                                userSession.LoggedIn    = true;
                                userSession.Email       = adminUser.email;
                                userSession.CurrentUser = accountDAL.FetchByID(adminUser.accountID);
                                return(RedirectToAction("AdminDashboard", "Admin"));
                            }

                            else if (adminUser == null)
                            {
                                userSession.LoggedIn    = true;
                                userSession.Email       = email;
                                userSession.CurrentUser = accountDAL.FetchByID(account.accountID);

                                if (account.Profile != null)
                                {
                                    if (account.Profile.isApproved == true)
                                    {
                                        return(RedirectToAction("Index", "UserDashboard"));
                                    }

                                    else if (account.Profile.isApproved == false)
                                    {
                                        return(RedirectToAction("ApplicationPending", "Profile"));
                                    }
                                }

                                else if (account.Profile == null)
                                {
                                    return(RedirectToAction("Create", "Profile"));
                                }
                                //return RedirectToAction("Register");
                            }
                        }

                        else
                        {
                            _email.SendEmailAddressVerificationEmail(account.email, account.email);
                            TempData["errorMessage"] = @"The login information you provided was correct 
                                but your email address has not yet been verified.  
                                We have just sent another email verification email to you.  
                                Please follow the instructions in that email.";
                        }
                    }
                    else
                    {
                        TempData["errorMessage"] = "Incorrect password ! ";
                    }
                }
                else
                {
                    TempData["errorMessage"] = "This account doesn't exist ! ";
                }
            }
            return(View(model));
        }