public void Update(UpdateRestaurantModel restaurantIn) { var update = Builders <Restaurant> .Update .Set(r => r.Email, restaurantIn.Email) .Set(r => r.RestaurantName, restaurantIn.RestaurantName) .Set(r => r.RestaurantType, restaurantIn.RestaurantType) .Set(r => r.Cvr, restaurantIn.Cvr) .Set(r => r.Address, restaurantIn.Address) .Set(r => r.PostalCode, restaurantIn.PostalCode) .Set(r => r.City, restaurantIn.City) .Set(r => r.Country, restaurantIn.Country); _restaurants.UpdateOne(r => r.Id == restaurantIn.Id, update); }
public static Restaurant ToRestaurant(this UpdateRestaurantModel restaurant) { return(new Restaurant() { Id = restaurant.Id, Email = restaurant.Email, RestaurantName = restaurant.RestaurantName, RestaurantType = restaurant.RestaurantType, Cvr = restaurant.Cvr, Address = restaurant.Address, PostalCode = restaurant.PostalCode, City = restaurant.City, Country = restaurant.Country }); }
public IActionResult Update([FromBody] UpdateRestaurantModel restaurantIn) { if (!ModelState.IsValid || restaurantIn == null) { return(BadRequest(ModelState)); } var restaurant = _restaurantService.Get(restaurantIn.Id); if (restaurant == null) { return(NotFound()); } _restaurantService.Update(restaurantIn); return(NoContent()); }