Exemple #1
0
        public ActionResult ConfirmPrivateCorkboard(ConfirmPrivateCorkboardViewModel model, int id)
        {
            //Checking the state of model passed as parameter.
            if (ModelState.IsValid)
            {
                //Validating the user, whether the user is valid or not.
                var isValidPassword = IsValidPassword(model);

                //If user is valid & present in database, we are redirecting it to Welcome page.
                if (isValidPassword != null)
                {
                    //FormsAuthentication.SetAuthCookie(model.Pin, false);

                    var corkboard = corkboardDbContext.Corkboards.SingleOrDefault(c => c.Cid == model.CId);
                    return(RedirectToAction("ViewCorkboard", "CorkBoard", new { id = id }));
                }
                else
                {
                    //If the username and password combination is not present in DB then error message is shown.
                    ModelState.AddModelError("Failure", "Wrong password !");
                    return(View());
                }
            }
            else
            {
                //If model state is not valid, the model with error message is returned to the View.
                return(View(model));
            }
        }
Exemple #2
0
        public ActionResult ConfirmPrivateCorkBoard(int id)
        {
            var viewModel = new ConfirmPrivateCorkboardViewModel
            {
                CId            = id,
                CorkboardTitle = corkboardDbContext.Corkboards.SingleOrDefault(c => c.Cid == id).Title
            };

            return(View(viewModel));
        }
Exemple #3
0
 //function to check if User is valid or not
 public User IsValidPassword(ConfirmPrivateCorkboardViewModel model)
 {
     using (var dataContext = new CorkBoardTemplateEntities())
     {
         //Retireving the user details from DB based on username and password enetered by user.
         string Email = User.Identity.Name;
         User   user  = dataContext.Users.Where(query => query.Email.Equals(Email) && query.Password.Equals(model.Pin)).SingleOrDefault();
         //If user is present, then true is returned.
         if (user == null)
         {
             return(null);
         }
         //If user is not present false is returned.
         else
         {
             return(user);
         }
     }
 }