public ActionResult LogIn(LoginModel loginModel, string returnUrl)

        {
            if (ModelState.IsValid)
            {
                var user = userManager.LogIn(loginModel.Email, loginModel.Password);

                if (user == null)
                {
                    ModelState.AddModelError("", "Email and password do not match.");
                }
                else
                {
                    Session["User"] = new Ziglearning.Website.Models.UserModel(user.Id, user.Name)
                    {
                        Id   = user.Id,
                        Name = user.Name
                    };

                    System.Web.Security.FormsAuthentication.SetAuthCookie(
                        loginModel.Email, false);

                    return(Redirect(returnUrl ?? "~/"));
                }
            }

            return(View(loginModel));
        }
        public ActionResult Register(RegisterModel registerModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var alreadyRegistered = userManager.AlreadyRegistered(registerModel.Email, registerModel.Password);


                if (alreadyRegistered != null)

                {
                    ModelState.AddModelError("", "You have already registered, please login instead.");
                }


                else
                {
                    if (registerModel.Email != "")
                    {
                        if (registerModel.Password != "")
                        {
                            if (registerModel.Password == registerModel.ConfirmPassword)

                            {
                                var user = userManager.Register(registerModel.Email, registerModel.Password);

                                Session["User"] = new Ziglearning.Website.Models.UserModel(user.Id, user.Name)
                                {
                                    Id   = user.Id,
                                    Name = user.Name
                                };

                                System.Web.Security.FormsAuthentication.SetAuthCookie(
                                    registerModel.Email, false);

                                return(Redirect(returnUrl ?? "~/"));
                            }

                            else

                            {
                                ModelState.AddModelError("", "Passwords do not match.");
                            }
                        }

                        else
                        {
                            ModelState.AddModelError("", "Password cannot be empty");
                        }
                    }

                    else
                    {
                        ModelState.AddModelError("", "Email cannot be empty");
                    }
                }

                RedirectToAction("Index");
                return(View(registerModel));
            }
            else
            {
                ModelState.AddModelError("", "There is a validation error.");
                return(View());
            }
        }