Exemplo n.º 1
0
        public ActionResult Login(Center aCenter)
        {
            if (aCenter.Code == null || aCenter.Password == null)
            {
                return(View(aCenter));
            }
            if (centerManager.DoesCodeExist(aCenter.Code))
            {
                aCenter = centerManager.GetCenterByLogIn(aCenter.Code, aCenter.Password);
                if (aCenter != null)
                {
                    FormsAuthentication.SetAuthCookie(aCenter.Name, false);
                    Session["centerLogin"] = aCenter;
                    Session["CenterId"]    = aCenter.Id;
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.Message = "Password is incorrect!!!";
                }
            }
            else
            {
                ViewBag.Message = "Invalid Center Code!!!";
            }

            return(View());
        }