public async Task GarageRegister(GarageRegisterDto garageRegisterDto) { try { //validacion de datos completos Throws.ThrowIfNull(garageRegisterDto, new BadRequestException("Los parametros son nulos.")); Throws.ThrowIfNull(garageRegisterDto.user_id, new BadRequestException("usuario esta vacio.")); Throws.ThrowIfNull(garageRegisterDto.altura_maxima, new BadRequestException("AlturaMaxima esta vacio.")); Throws.ThrowIfEmpty(garageRegisterDto.coordenadas, new BadRequestException("coordenadas esta vacio.")); Throws.ThrowIfEmpty(garageRegisterDto.direccion, new BadRequestException("direccion esta vacio.")); Throws.ThrowIfNull(garageRegisterDto.localidad_garage, new BadRequestException("localidad garage esta vacio.")); Throws.ThrowIfNull(garageRegisterDto.lugar_autos, new BadRequestException("lugar autos esta vacio.")); Throws.ThrowIfNull(garageRegisterDto.lugar_bicicletas, new BadRequestException("lugar bicicletas esta vacio.")); Throws.ThrowIfNull(garageRegisterDto.lugar_camionetas, new BadRequestException("lugar camionetas esta vacio.")); Throws.ThrowIfNull(garageRegisterDto.lugar_motos, new BadRequestException("lugar motos esta vacio.")); Throws.ThrowIfEmpty(garageRegisterDto.nombre_garage, new BadRequestException("nombre garage esta vacio.")); Throws.ThrowIfEmpty(garageRegisterDto.telefono, new BadRequestException("telefono esta vacio.")); //DataBase await _guardameLugarDacService.GarageRegister(garageRegisterDto); } catch (Exception e) { _logger.LogError(e, GetType().Name + "." + MethodBase.GetCurrentMethod().Name); throw; } }
public async Task SaveUser(UserDto userDto) { try { //validacion de datos completos Throws.ThrowIfNull(userDto, new BadRequestException("Los parametros son nulos.")); Throws.ThrowIfEmpty(userDto.apellido, new BadRequestException("Apellido esta vacio.")); Throws.ThrowIfEmpty(userDto.contraseña, new BadRequestException("contraseña esta vacio.")); Throws.ThrowIfEmpty(userDto.mail, new BadRequestException("mail esta vacio.")); Throws.ThrowIfEmpty(userDto.nombre, new BadRequestException("nombre esta vacio.")); Throws.ThrowIfNull(userDto.rol, new BadRequestException("rol esta vacio.")); Throws.ThrowIfEmpty(userDto.telefono, new BadRequestException("telefono esta vacio.")); //validar unico mail string mail = userDto.mail; bool mailvalidator = await _guardameLugarDacService.MailValidation(mail); if (mailvalidator) { throw new BadRequestException("Este mail ya fue registrado."); } //encriptacion userDto.contraseña = EncriptingPass.GetSHA256(userDto.contraseña); //DataBase await _guardameLugarDacService.SaveUser(userDto); } catch (Exception e) { _logger.LogError(e, GetType().Name + "." + MethodBase.GetCurrentMethod().Name); throw; } }
public async Task UpdateGarage(UpdateGarageDto updateGarageDto) { //Valido los campos necesarios Throws.ThrowIfNull(updateGarageDto, new BadRequestException("Los parametros son nulos.")); Throws.ThrowIfNull(updateGarageDto.altura_maxima, new BadRequestException("AlturaMaxima esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.coordenadas, new BadRequestException("coordenadas esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.direccion, new BadRequestException("direccion esta vacio.")); Throws.ThrowIfNull(updateGarageDto.localidad_garage, new BadRequestException("localidad garage esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_autos, new BadRequestException("lugar autos esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_bicicletas, new BadRequestException("lugar bicicletas esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_camionetas, new BadRequestException("lugar camionetas esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_camionetas, new BadRequestException("lugar camionetas esta vacio.")); Throws.ThrowIfNull(updateGarageDto.lugar_motos, new BadRequestException("lugar motos esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.nombre_garage, new BadRequestException("nombre garage esta vacio.")); Throws.ThrowIfEmpty(updateGarageDto.telefono, new BadRequestException("telefono esta vacio.")); Throws.ThrowIfNull(updateGarageDto.garage_id, new BadRequestException("garage_id esta vacio.")); //hago el update await _guardameLugarDacService.UpdateGarage(updateGarageDto); }
public async Task <LogInDto> LogInUser(string user, string password) { try { Throws.ThrowIfEmpty(user, new BadRequestException("user esta vacio.")); Throws.ThrowIfEmpty(password, new BadRequestException("Pasword esta vacio.")); if (password.Length <= 15) { password = EncriptingPass.GetSHA256(password); } var userData = await _guardameLugarDacService.LogInUser(user, password); Throws.ThrowIfNull(userData, new NotFoundException($"No se encontro el usuario: {user}.")); return(userData); } catch (Exception e) { _logger.LogError(e, GetType().Name + "." + MethodBase.GetCurrentMethod().Name); throw; } }