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()); } }
public ActionResult SearchArticle(string searchText) { try { var user = ((User)Session["Login"]).Username; List <Article> lstSearch = articleManager.SearchArticles(searchText); logger.Log("", LogType.Search, user); return(View(lstSearch)); } catch (Exception e) { ViewBag.ErrorTitle = "Server Error"; ViewBag.ErrorDescription = "Please try again later"; return(View("~/Views/Shared/ErrorPage.cshtml")); } }