public ActionResult Login(AccountViewModel account)
 {
     if (ModelState.IsValid)
     {
         if (MembershipService.ValidateUser(account.Username, account.Password))
         {
             Session["Username"] = account.Username;
             return View("Main", account);
         }
         else
         {
             ModelState.AddModelError("", "Either username or password is incorrect");
         }
     }
     return View("Login", account);
 }
        public ActionResult Registration(AccountViewModel account)
        {
            if (ModelState.IsValid)
            {
                if (MembershipService.UsernameExists(account.Username))
                {
                    ModelState.AddModelError("", "Username " + account.Username + " already exists. Please pick another one.");
                }
                else
                {
                    MembershipService.CreateUser(account);
                    return RedirectToAction("Login");
                }
            }

            return View("Registration", account);
        }
 public void CreateUser(AccountViewModel user)
 {
     if (!(IsNullOrEmpty(user.Username) && IsNullOrEmpty(user.Password)))
     {
         usersRepository.CreateUser(user.Username, user.Password);
     }
 }