Exemple #1
0
        public CompanyDto IsValidCompany(string username, string password)
        {
            var company    = new Company();
            var companyDto = new CompanyDto {
                AddressDto = new AddressDto(), MenuListDto = new List <MenuDto>()
            };

            try
            {
                bool bRet = false;
                company = FirstOrDefault(x => x.Username == username);
                if (company != null)
                {
                    var loginInfo = new LoginInfoCreate();
                    loginInfo.PasswordHash = company.Account.passwordHash;
                    loginInfo.SaltVal      = company.Account.passwordSalt.ToString();
                    bRet = PasswordHashHelper.ValidatePasswordHash(loginInfo, password);

                    if (bRet)
                    {
                        CopyTocompanyDto(companyDto, company);
                        return(companyDto);
                    }
                    else
                    {
                        companyDto = null;
                    }
                }
                else
                {
                    companyDto = null;
                }
            }
            catch (Exception e)
            {
                companyDto = null;
            }
            return(companyDto);
        }