public ActionResult Login(LoginViewModel model)
        {
            bool modelValid = true;
            if (string.IsNullOrWhiteSpace(model.UserName))
            {
                ModelState.AddModelError("UserName", "Please provide user name");
                modelValid = false;
            }

            if (string.IsNullOrWhiteSpace(model.Password))
            {
                ModelState.AddModelError("Password", "Please provide password");
                modelValid = false;
            }

            if (!modelValid)
                return View(model);

            try
            {
                bool authenticated = WebSecurity.Login(model.UserName, model.Password);
                if (authenticated)
                {
                    return RedirectToAction("Index", "Home");
                }
                else
                {
                    TempData["Notification"] = new Notification("Incorrect username/password pair.", Nature.warning);
                    return View();
                }
            }
            catch (Exception ex)
            {
                ViewBag.Notification = new Notification("Error occured when processing your request", Nature.danger);
                return View("Error");
            }
        }
 public ActionResult Login()
 {
     LoginViewModel viewModel = new LoginViewModel();
     return View(viewModel);
 }