public void DeveSerInvalidoComNameVazioOuNulo() { var input = new NewRestaurantInputModel { Address = "Av. Araxá", Category = "Restaurante", Location = "Goiânia" }; Assert.False(input.IsValid); }
public void DeveSerValidoComInformacoesPreenchidas() { var input = new NewRestaurantInputModel { Name = "Restaurante", Category = "Restaurante", Address = "Av. Araxá", Location = "Goiânia" }; Assert.True(input.IsValid); }
public async Task <Result> Add(NewRestaurantInputModel input) { if (!input.IsValid) { return(Result.Error(input.ValidationResult.ToErrorList())); } var restaurant = _mapper.Map <Restaurant>(input); await _repository.Insert(restaurant); return(Result.Success()); }
public async Task <ActionResult <Result> > Create([FromBody] NewRestaurantInputModel input) { try { var result = await _service.Add(input); return(ReturnResult(result)); } catch (Exception ex) { return(ReturnResult(Result.Error(ex))); } }