public ActionResult Index(RegistrationViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Result = _RegistrationRepository.ClientAuthentication(model.Email, model.Password);
                if (Result != null)
                {
                    if (Result.Email.ToLower() == model.Email.ToLower() && Result.Password == model.Password)
                    {
                        if (!Result.ActiveStatus)
                        {
                            ViewBag.error = "User not active please contact to admin";
                            return(View(model));
                        }
                        Session["UserName"]       = Result.FirstName + " " + Result.LastName;
                        Session["UserId"]         = Result.RegistId;
                        Session["MemberType"]     = Result.MemberType;
                        Session["PaymentStatus"]  = Result.PaymentStatus;
                        Session["MemberShipType"] = Result.MemberShipType;

                        if (Result.MemberType == (string)ConfigurationManager.AppSettings["AdminType"])
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        ViewBag.error = "User name password wrong please try again.";
                        return(View(model));
                    }
                }
                else
                {
                    ViewBag.error = "User name password wrong please try again.";
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }
Esempio n. 2
0
        public ActionResult Login(LoginViewModel model)
        {
            if (ModelState.IsValid)
            {
                var Result = _RegistrationRepository.ClientAuthentication(model.Email, model.Password);
                if (Result != null)
                {
                    if (Result.Email.ToLower() == model.Email.ToLower() && Result.Password == model.Password)
                    {
                        if (!Result.ActiveStatus)
                        {
                            TempData["Error"] = "User not active please contact to admin";
                            TempData.Keep();
                            return(View(model));
                        }
                        Session["UserName"]       = Result.FirstName + " " + Result.LastName;
                        Session["UserId"]         = Result.RegistId;
                        Session["MemberType"]     = Result.MemberType;
                        Session["MemberShipType"] = Result.MemberShipType;
                        Session["PaymentStatus"]  = Result.PaymentStatus;

                        //save Email password in session
                        Session["Email"]    = Result.Email;
                        Session["Password"] = Result.Password;

                        if (Result.MemberType == "SuppeAdmin")
                        {
                            return(RedirectToAction("Index", "Client"));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        ViewBag.error = "User name password wrong please try again.";
                        return(View(model));
                    }
                }
                else
                {
                    ViewBag.error = "User name password wrong please try again.";
                    return(View(model));
                }
            }
            else
            {
                return(View(model));
            }
        }