Пример #1
0
        public ActionResult Login(User user, string returnUrl)
        {
            try
            {
                if (userManager.ValidateLogin(ref user))
                {
                    logger.Log("", LogType.Login, user.Username);

                    Session["Login"] = user;
                    Json(comManager.GetUnreadCommentsCount(((User)Session["Login"]).Id), JsonRequestBehavior.AllowGet);
                    return(RedirectToAction("Home"));
                }
                else
                {
                    if (user.Username == null || user.Password == null)
                    {
                        ModelState.AddModelError(string.Empty, "All fields are required");
                        return(View());
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Username or password is invalid");
                        return(View());
                    }
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError(string.Empty, "Server Error, please try again later");
                return(View());
            }
        }
Пример #2
0
 public ActionResult GetNotificationCount()
 {
     try
     {
         return(Json(commentManager.GetUnreadCommentsCount(((User)Session["Login"]).Id), JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         ViewBag.ErrorTitle       = "Server Error";
         ViewBag.ErrorDescription = "Please try again later";
         return(View("~/Views/Shared/ErrorPage.cshtml"));
     }
 }