// /restaurants -> Get All Restaurants // /restaurants/{Id} -> Get Restaurant By Id public object Get(RestaurantMenu.Dto.Restaurant request) { var response = new RestaurantResponse(); try { if (request.Id.HasValue) { var restaurant = GetById(request.Id.Value); response.Restaurants.Add(restaurant); response.Result = "1 Restaurant was found"; } else { response.Restaurants = GetAll(); response.Result = "3 Restaurants were found"; } } catch (Exception) { throw; } return(response); }
public async void RefreshList() { if (IsBusy) { return; } IsBusy = true; isRefreshingList = true; StatusText = "Getting new data..."; RestaurantResponse response = await dataService.getAllRestaurants(); if (response != null) { if (response.status.Equals("success")) { int colorFlipper = 0; List <RestaurantItem> items = new List <RestaurantItem>(); foreach (RestaurantItem row in response.data) { if (row.image == null || row.image.Length == 0) { row.image = "img_na_placeholder.png"; } if ((colorFlipper % 2) == 0) { row.background = Color.FromHex("#FFFFFF"); } else { row.background = Color.FromHex("#99999D"); } items.Add(row); colorFlipper++; } RestaurantsList = new ObservableCollection <RestaurantItem>(items); RestaurantsList.OrderByDescending(x => x.entry_datetime); if (RestaurantsList.Count() > 0) { IsHasDataFlag = false; } else { StatusText = "No Data Available"; IsHasDataFlag = true; } } } else { StatusText = "Service is Unavailable"; } IsBusy = false; isRefreshingList = false; }
/// <summary> /// Deserialize Restaurant API Response /// </summary> /// <param name="response">The <see cref="HttpResponseMessage"/></param> /// <returns>List of <see cref="Restaurant"/></returns> private async Task <List <Restaurant> > DeserializeResponse(HttpResponseMessage response) { string json = await response.Content.ReadAsStringAsync(); RestaurantResponse currentResponse = Newtonsoft.Json.JsonConvert.DeserializeObject <RestaurantResponse>(json); return(currentResponse.Restaurants); }
public IActionResult EnterRestaurant(RestaurantResponse restaurant) { if (ModelState.IsValid) { TempStorage.AddRestaurant(restaurant); Response.Redirect("RestaurantList"); } return View(); }
public IActionResult RestaurantInsert(RestaurantResponse restaurant) { if (ModelState.IsValid) { TempStorage.AddRestaurant(restaurant); return(View("Confirmation", restaurant)); } else { return(View()); } }
public ActionResult Index(RestaurantResponse restaurantResponse, string request) { // Check to see if the restaurant information is valid. if (ModelState.IsValid) { // Check to see if any special request was made. if (request == "") { // No request was made, so set the text as none. request = "None"; } // If the information is valid, send the resonse to the Restaurant Thanks view. return(View("RestaurantThanks", new Tuple <RestaurantResponse, string> (restaurantResponse, request))); } else { // Otherwise, there is a validation error. return(View()); } }
public ActionResult <OrderResponse> RegisterOrder([FromBody] OrderRequest orderRequest) { if (!ModelState.IsValid) { throw new BadRequestException("0003", "badRequestException", "Verify list of field with errors", ModelState); } List <OrderedItem> items = orderRequest.Items.ConvertAll(itemRequest => new OrderedItem(itemRequest.Uuid, itemRequest.Amount, itemRequest.UnitValue)); Ordered orderToRegister = new Ordered(orderRequest.RestaurantUuid, items); Order order = _registerOrder.Execute(orderToRegister); var restaurantResponse = new RestaurantResponse(order.Restaurant.Uuid, order.Restaurant.Name); List <OrderItemResponse> orderItemResponses = order.Items.Select(orderItem => new OrderItemResponse(orderItem.Uuid, orderItem.Name, orderItem.Amount, orderItem.UnitValue)) .ToList(); OrderResponse orderResponse = new OrderResponse(order.Uuid, restaurantResponse, orderItemResponses, order.Total); return(Ok(new DataResponse <OrderResponse>(orderResponse))); }