//ListRestaurant.PersonRestaurant.Restaurant //Both ListRestaurant and PersonRestaurant converts to ListRestaurantDTO //This is because when you're getting a list of PersonRestaurant, its usually as Goals or Visited, which is treated as if they were lists themselves public ListRestaurantDTO Create(ListRestaurant listRestaurant) { return(new ListRestaurantDTO() { ID = listRestaurant.ID, ListComment = listRestaurant.Comment, Sequence = listRestaurant.Sequence, CreatedOn = listRestaurant.CreatedOn, LastEdited = listRestaurant.LastEdited, RestaurantID = listRestaurant?.PersonRestaurant?.Restaurant?.ID != null ? listRestaurant.PersonRestaurant.Restaurant.ID: 0, Name = listRestaurant?.PersonRestaurant?.Restaurant?.Name, Address = listRestaurant?.PersonRestaurant?.Restaurant?.Address, Summary = listRestaurant?.PersonRestaurant?.Restaurant?.Summary, HasVisited = listRestaurant?.PersonRestaurant?.HasVisited != null ? listRestaurant.PersonRestaurant.HasVisited : false, Priority = listRestaurant?.PersonRestaurant?.Priority != null ? listRestaurant.PersonRestaurant.Priority : 0, Rating = listRestaurant?.PersonRestaurant?.Rating != null ? listRestaurant.PersonRestaurant.Rating : 0, LastVisited = listRestaurant?.PersonRestaurant?.LastVisited, Review = listRestaurant?.PersonRestaurant?.Review, ReviewIsVisible = listRestaurant?.PersonRestaurant?.ReviewIsVisible != null ? listRestaurant.PersonRestaurant.ReviewIsVisible : false, Notes = listRestaurant?.PersonRestaurant?.Notes, IsListRestaurant = true }); }
// PUT: api/Delivery/5 public async Task <ApiResponse <List <DeliveryInfos> > > Put(int IdService, int city_id, [FromBody] ListRestaurant data) { try { _deliveryService.GetExternalServiceById(IdService); List <Restaurant> newList = new List <Restaurant>(); if (data.restaurant_ids.Count() < 1) { ApiUtil <List <DeliveryInfos> > .CreateFailResult(""); } foreach (var id in data.restaurant_ids)//get the fisrt catalogue { Restaurant item = new Restaurant(); item.restaurant_id = id.ToString(); newList.Add(item); } return(ApiUtil <List <DeliveryInfos> > .CreateSuccessfulResult( await _deliveryService.GetRestaurantsDeliveryInforAsync(city_id, newList) )); } catch (Exception e) { return(ApiUtil <List <DeliveryInfos> > .CreateFailResult(e.ToString())); } }