Пример #1
0
        public async Task <ActionResult> DoLogin(DoLoginViewModel model)
        {
            bool isExist = false;

            using (var chanel = new ChanelFactory())
            {
                isExist = await chanel.CheckCusExist <bool>(model.CustomerCode.Trim());

                if (isExist)
                {
                    var result = await chanel.Login <bool>(model.CustomerCode.Trim(), model.Password);

                    if (result)
                    {
                        FormsAuthentication.SetAuthCookie(model.CustomerCode, false);
                        return(Json(new { IsSuccess = true }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new { IsSuccess = false, Error = Einvoice_Customer.Language.Resource.ErrorPass }, JsonRequestBehavior.AllowGet));
                    }
                }
                else
                {
                    return(Json(new { IsSuccess = false, Error = Einvoice_Customer.Language.Resource.usernotExist }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Пример #2
0
        public async Task <ActionResult> Login(LoginViewModel model, string returnUrl)
        {
            bool isExist = false;

            using (var chanel = new ChanelFactory())
            {
                isExist = await chanel.CheckCusExist <bool>(model.CustomerCode.Trim());

                if (isExist)
                {
                    var result = await chanel.Login <bool>(model.CustomerCode.Trim(), model.Password);

                    if (result)
                    {
                        FormsAuthentication.SetAuthCookie(model.CustomerCode, false);
                        if (model.CustomerCode == "admin")
                        {
                            return(RedirectToAction("About", "Home"));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "EinvoiceCustomer"));
                        }
                    }
                    else
                    {
                        ModelState.AddModelError("", Einvoice_Customer.Language.Resource.accountnotExist);
                    }
                }
                else // không có trong data, kiểm tra trên hệ thống
                {
                    ModelState.AddModelError("", Einvoice_Customer.Language.Resource.usernotExist);
                }
            }
            return(View(model));
        }