public async Task <int> UpdateCartOnItemStock(ItemOutOfStock outOfStock) { string RestaurantApiUrl = "http://localhost:11789/"; using (HttpClient httpClient = WebAPIClient.GetClient(outOfStock.UserToken, outOfStock.UserID, RestaurantApiUrl)) { //GET Method HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/UpdateCartOnItemStock?RestaurantID=" + outOfStock.RestaurantId + "&MenuID=" + outOfStock.MenuId); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); int retVal = JsonConvert.DeserializeObject <int>(json); if (retVal != 0) { return(1); } else { return(0); } } } return(-1); }
public async Task <bool> IsValidRestaurantAsync(RatingandReviewDetails ratingEntity, int UserId, string UserToken) { //HttpClient client = new HttpClient(); //client.BaseAddress = new Uri("http://localhost:10603/"); //HttpResponseMessage httpResponseMessage = await client.GetAsync("api/ResturantDetail?RestaurantID=" + ratingEntity.TblRestaurantId); //if(httpResponseMessage.IsSuccessStatusCode) //{ // string json = await httpResponseMessage.Content.ReadAsStringAsync(); // RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject<RestaurantInformation>(json); // if(restaurantInformation!=null) // { // return true; // } //} //return false; using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, "http://localhost:10603/")) { HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/ResturantDetail?RestaurantID=" + ratingEntity.TblRestaurantId); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject <RestaurantInformation>(json); if (restaurantInformation != null) { return(true); } } } return(false); }
public async Task <int> UpdateCartPriceChange(PriceChangeItem priceChange) { string RestaurantApiUrl = "http://localhost:11789/"; using (HttpClient httpClient = WebAPIClient.GetClient(priceChange.UserToken, priceChange.UserID, RestaurantApiUrl)) { //GET Method HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/CartItemPriceChange?RestaurantID=" + priceChange.RestaurantId + "&MenuID=" + priceChange.MenuId + "&Price=" + priceChange.Price); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); int retVal = JsonConvert.DeserializeObject <int>(json); if (retVal != 0) { return(1); } else { return(0); } } } return(-1); }
public async Task <bool> IsOrderItemInStock(OrderEntity orderEntity, int UserId, string UserToken) { bool flag = true; using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, _connectionStrings.Value.RestaurantApiUrl = "https://restaurentmanagement.azurewebsites.net/api/OrderDetails?orderedmenuitems=")) //using (HttpClient httpClient = new HttpClient()) { var ordermenudetails = JsonConvert.SerializeObject(orderEntity.OrderMenuDetails); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(_connectionStrings.Value.RestaurantApiUrl + ordermenudetails); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); List <OrderedMeniItems> ordereditems = JsonConvert.DeserializeObject <List <OrderedMeniItems> >(json); if (ordereditems != null) { foreach (var item in ordereditems) { if (item.quantity == 0) { flag = false; CartItemsEntity cart = new CartItemsEntity() { Status = false, TblMenuID = item.menu_ID, Price = item.price, Itemavailabilitystatus = "OutofStock", TblRestaurantID = orderEntity.RestaurantId }; _cartActions.UpdateCartitemstatus(cart); } else if (item.quantity == -1) { flag = false; CartItemsEntity cart = new CartItemsEntity() { Status = false, TblMenuID = item.menu_ID, Price = item.price, Itemavailabilitystatus = "Requested Quantity Not Available", TblRestaurantID = orderEntity.RestaurantId }; _cartActions.UpdateCartitemstatus(cart); } } return(flag); } } } return(false); }
public async Task <bool> IsValidRestaurantAsync(AddToCartEntity cartEntity, int UserId, string UserToken) { using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, _connectionStrings.Value.RestaurantApiUrl)) { HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/ResturantDetail?RestaurantID=" + cartEntity.RestaurantId); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); RestaurantInformation restaurantInformation = JsonConvert.DeserializeObject <RestaurantInformation>(json); if (restaurantInformation != null) { return(true); } } } return(false); }
public async Task <bool> IsValidCustomer(int UserId, string UserToken, int CustomerID) { _connectionStrings.Value.RestaurantApiUrl = "http://localhost:12697/"; using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, _connectionStrings.Value.RestaurantApiUrl)) { HttpResponseMessage httpResponseMessage = await httpClient.GetAsync("api/Security/ValidateCustomerID?CustomerID=" + CustomerID); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); int Customer = JsonConvert.DeserializeObject <int>(json); if (Customer != 0) { return(true); } } } return(false); }
public async Task <bool> IsValidOfferAsync(OrderEntity orderEntity, int UserId, string UserToken) { using (HttpClient httpClient = WebAPIClient.GetClient(UserToken, UserId, _connectionStrings.Value.RestaurantApiUrl = "https://restaurentmanagement.azurewebsites.net/api/OfferForMenu?orderedmenuitems=")) //using (HttpClient httpClient = new HttpClient()) { var val = JsonConvert.SerializeObject(orderEntity.OrderMenuDetails); HttpResponseMessage httpResponseMessage = await httpClient.GetAsync(_connectionStrings.Value.RestaurantApiUrl + val); if (httpResponseMessage.IsSuccessStatusCode) { string json = await httpResponseMessage.Content.ReadAsStringAsync(); List <OrderedMeniItems> ordereditems = JsonConvert.DeserializeObject <List <OrderedMeniItems> >(json); if (ordereditems != null) { return(true); } } } return(false); }