public ActionResult LogOn(LogOnModel logOnModel, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                logOnModel.Password = Convert.ToBase64String(
                    new System.Security.Cryptography.SHA1CryptoServiceProvider().ComputeHash(
                        Encoding.ASCII.GetBytes(logOnModel.Password)));

                if (AccountRepository.LogOn(logOnModel))
                {
                    FormsService.SignIn(logOnModel.UserName, logOnModel.RememberMe);

                    if (!String.IsNullOrEmpty(returnUrl))
                    {
                        return Redirect(returnUrl);
                    }
                    else
                    {
                        return RedirectToAction("Index", "Home");
                    }
                }
                else
                {
                    ModelState.AddModelError("", "The user name or password provided is incorrect.");
                }
            }

            // If we got this far, something failed, redisplay form
            //return View(new LogOnViewModel(logOnModel));

            return View(new LogOnModel());
        }
        public bool LogOn(LogOnModel logOnModel)
        {
            using (Entities entity = new Entities(BaseBISL.ConnectionString))
            {
                var user = entity.WeightUsers.Where
                    (e => e.UserName == logOnModel.UserName && e.PW == logOnModel.Password).FirstOrDefault();

                if (user != null)
                {
                    return true;
                }
                return false;
            }
        }