public async Task <bool> AddAccount(AccountDto dto, IHttpContextAccessor context) { if (_ragnarokConfigurations.UseMd5Pass) { dto.user_pass = Md5Converter.Hash(dto.user_pass); } string ipAddress = context.HttpContext.Connection.RemoteIpAddress.ToString(); if (!string.IsNullOrEmpty(ipAddress)) { string[] addresses = ipAddress.Split(','); if (addresses.Length != 0) { dto.last_ip = addresses[0]; } else { dto.last_ip = ipAddress; } } var entity = _mapper.Map <AccountEntity>(dto); await _accountRepository.Add(entity); await _accountRepository.SaveChanges(); return(entity.account_id > 0 ? true : false); }
public bool ValidateLogin(LoginDto dto) { if (_ragnarokConfigurations.UseMd5Pass) { dto.user_pass = Md5Converter.Hash(dto.user_pass); } var user = _repo.GetAll().Where(s => s.userid == dto.userid && s.user_pass == dto.user_pass).ToList(); if (user.Count == 1) { return(true); } return(false); }