Exemplo n.º 1
0
        public async Task <IHttpActionResult> PutLocation(Guid id, LocationViewModel location)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != location.Id)
            {
                return(BadRequest());
            }

            location.Id = id;

            try
            {
                await _locationRepository.EditAsync(location.ToModel());
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocationExist(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }