예제 #1
0
        public async Task <ActionResult <City> > UpdateCityAsync(int id, City city)
        {
            if (id != city.Id)
            {
                return(BadRequest());
            }

            var updateReturn = await _cityRepository.Update(id, city);

            if (updateReturn != null)
            {
                return(Ok(city));
            }

            return(BadRequest());
        }
예제 #2
0
        public async Task <ActionResult <User> > UpdateUserAsync(int id, User user)
        {
            try
            {
                if (id != user.Id)
                {
                    return(BadRequest());
                }

                var updateReturn = await _userRepository.Update(id, user);

                if (updateReturn != null)
                {
                    return(Ok(user));
                }

                return(BadRequest());
            }
            catch (Exception e)
            {
                return(BadRequest(new { message = "Error to update user", exception = e.Message, innerExeption = e.InnerException?.Message }));
            }
        }