public ActionResult <CreateRestaurant> CreateRestaurant([FromBody] CreateRestaurant model) { try { var restaurantType = _repository.GetRestaurantTypeByID(model.RestaurantTypeID); if (restaurantType == null) { return(BadRequest("Restaurant type could not be find")); } var cuisineType = _repository.GetCuisineTypeById(model.CuisineTypeID); if (cuisineType == null) { return(BadRequest("Cuisine type could not be find")); } IMapper mapper = EDeliveryProfile.CreateRestaurant(); var restaurant = mapper.Map <Restaurant>(model); _repository.CreateNewRestaurant(restaurant); return(new ObjectResult(new { message = "success", statusCode = HttpStatusCode.OK, response = "Created restaurant" })); } catch (Exception ex) { _logger.LogError($"Failed to create new restaurant:{ex}"); return(BadRequest("Failed to create new restaurant: ")); } }