Exemplo n.º 1
0
        public IActionResult Post([FromBody] CountyDTO model)
        {
            County county;

            try
            {
                county = _mapper.Map <County>(model);
            }
            catch
            {
                return(BadRequest("No Mapping"));
            }
            try
            {
                _repo.Add(county);
            }
            catch
            {
                return(BadRequest("No Save"));
            }

            var newUri = Url.Link("Get", new { id = county.Id });

            return(Created(newUri, _mapper.Map <CountyDTO>(county)));
        }
Exemplo n.º 2
0
        public async Task <ResponseCRUDMessage> Add(Cars car)
        {
            var response = new ResponseCRUDMessage(false, "");

            try
            {
                response.status = await carsRepository.Add(car);

                response.message = "The car was created!";
            }
            catch (Exception ex)
            {
                response.message = ex.Message;
            }
            return(response);
        }