Ejemplo n.º 1
0
        public ActionResult Login(string Email, string Password)
        {
            //BienSoXe = BienSoXe + "@chonve.vn";
            var loginresult = _customerRegistrationService.ValidateCustomer(Email, Password);

            if (loginresult != CustomerLoginResults.Successful)
            {
                return(ErrorOccured("Tài khoản hoặc mật khẩu không đúng !"));
            }
            _customer = _customerService.GetCustomerByEmail(Email);

            //kiem tra co quyen ko
            if (!isRightAccess())
            {
                return(ErrorOccured("Bạn không có quyền vào chức năng này !"));
            }
            //kiem tra cac thong tin nha xe
            NhaXe currentNhaXe = _nhaxeService.GetNhaXeByCustommerId(currentCustomer.Id);

            if (currentNhaXe == null)
            {
                return(ErrorOccured("Không xác định nhà xe !"));
            }
            //luu nhat ky
            _customerActivityService.InsertActivity("PublicStore.Login", "Tài khoản nhà xe đăng nhập", currentCustomer);
            //lay thong tin van phong
            _nhanvien = _nhanvienService.GetByCustomerId(currentCustomer.Id);
            //OK, lay thong tin va truyen xuong client
            var loginInfo = new
            {
                Id         = currentCustomer.Id,
                NhaXeId    = currentNhaXe.Id,
                GuidId     = _settings.ApiToken,
                FullName   = currentCustomer.GetFullName(),
                TenNhaXe   = currentNhaXe.TenNhaXe,
                VanPhongId = _nhanvien.VanPhongID.GetValueOrDefault(0)
            };

            return(Successful(loginInfo));
        }