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> 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 StoreModel GetStore(int storeId, ISystemResponse error) { StoreModel store = new StoreModel(); try { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("storeId", storeId.ToString()); string request = WebAPIClient.GetRequest("Stores", "Get", parameters, error); if (!string.IsNullOrEmpty(request) && !error.Error) { JavaScriptSerializer serializer = new JavaScriptSerializer(); StoreResponseModel response = serializer.Deserialize <StoreResponseModel>(request); if (response != null && !error.Error && response.store != null) { store = response.store; } } } catch (Exception ex) { error.Error = true; error.Message = "No se pudo obtener la informacion de la tienda solicitada"; error.Exception = ex; } return(store); }
public Article GetArticle(int articleId, ISystemResponse error) { Article article = new Article(); try { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("articleId", articleId.ToString()); parameters.Add("bit", "false"); string request = WebAPIClient.GetRequest("Articles", "Get", parameters, error); if (!string.IsNullOrEmpty(request) && !error.Error) { JavaScriptSerializer serializer = new JavaScriptSerializer(); ArticleResponseModel response = serializer.Deserialize <ArticleResponseModel>(request); if (response != null && !error.Error && response.article != null) { article = response.article; } } } catch (Exception ex) { error.Error = true; error.Message = "No se pudo obtener la informacion del articulo solicitado"; error.Exception = ex; } return(article); }
private string ConnectToDataProvider(string DataProviderURL) { WebAPIClient client = new WebAPIClient(); string guid = client.ConnectToDataProvider(DataProviderURL); return(guid); }
public List <ArticleModel> GetArticles(ISystemResponse error) { List <ArticleModel> articles = new List <ArticleModel>(); try { string request = WebAPIClient.GetRequest("Articles", "Get", new Dictionary <string, string>(), error); if (!string.IsNullOrEmpty(request) && !error.Error) { JavaScriptSerializer serializer = new JavaScriptSerializer(); ArticlesResponseModel response = serializer.Deserialize <ArticlesResponseModel>(request); if (response != null && !error.Error && response.articles != null) { articles = response.articles; } } } catch (Exception ex) { error.Error = true; error.Message = "No se pudieron obtener los articulos"; error.Exception = ex; } return(articles); }
public bool UpdateStore(StoreModel store, ISystemResponse error) { bool updated = false; try { string request = WebAPIClient.PutRequest("Stores", "", store, error, new Dictionary <string, string>()); if (!string.IsNullOrEmpty(request) && !error.Error) { JavaScriptSerializer serializer = new JavaScriptSerializer(); BasicResponseModel response = serializer.Deserialize <BasicResponseModel>(request); if (response != null && !error.Error) { updated = response.success; } } } catch (Exception ex) { error.Error = true; error.Message = "No fue posible actualizar la tienda"; error.Exception = ex; } return(updated); }
public bool CreateArticle(Article article, ISystemResponse error) { bool created = false; try { string request = WebAPIClient.PostRequest("Articles", "", article, error, new Dictionary <string, string>()); if (!string.IsNullOrEmpty(request) && !error.Error) { JavaScriptSerializer serializer = new JavaScriptSerializer(); BasicResponseModel response = serializer.Deserialize <BasicResponseModel>(request); if (response != null && !error.Error) { created = response.success; } } } catch (Exception ex) { error.Error = true; error.Message = "No fue posible crear el articulo"; error.Exception = ex; } return(created); }
public static dynamic ApiLogin(string email, string password) { //POST Profile profile = new Profile { id = 0, name = "string" }; AdminApi admApi = new AdminApi { address = "string", city = "string", country = "string", email = email, fullName = "string", id = 0, idProfile = 0, password = password, profile = profile, status = 0 }; var url = URL_VIRTUAL_FAIR_USER; var urlMethod = "findByEmailAndPassword"; WebAPIClient clientAPI = new WebAPIClient(url); var paramApi = urlMethod; var content = JsonConvert.SerializeObject(admApi); var body = new StringContent(content, Encoding.UTF8, UtilWebApiMethod.TypeJson); var response = clientAPI.HttpClient.PostAsync(paramApi, body); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
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 bool DeleteArticle(int articleId, ISystemResponse error) { bool deleted = false; try { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("articleId", articleId.ToString()); string request = WebAPIClient.DeleteRequest("Articles", "", error, parameters); if (!string.IsNullOrEmpty(request) && !error.Error) { JavaScriptSerializer serializer = new JavaScriptSerializer(); BasicResponseModel response = serializer.Deserialize <BasicResponseModel>(request); if (response != null && !error.Error) { deleted = response.success; } } } catch (Exception ex) { error.Error = true; error.Message = "No fue posible eliminar"; error.Exception = ex; } return(deleted); }
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 MainWindow() { InitializeComponent(); startDate.Text = DateTime.Today.AddDays(-1).ToShortDateString(); endDate.Text = DateTime.Today.ToShortDateString(); api = new WebAPIClient("BasicHttpBinding_WebAPI"); App.ApplySettingsFromReg(App.WebAPI, user, pass, EndpointURL); gatewayID.Text = App.GetRegString(RegGateway); uploadData.Text = App.GetRegString(RegUploadData); }
public ManagementViewModel() { _userApi = new WebAPIClient(new Uri("https://localhost:44319/"), new BasicAuthenticationCredentials()); _venueService = new VenueServiceClient(); _layoutService = new LayoutServiceClient(); _areaService = new AreaServiceClient(); _seatService = new SeatServiceClient(); UsersInit(); VenueLayoutTreeInit(); AreaSeatListInit(); }
public async Task <ResponseResult> LogoutSync() { var url = ImageWebAPIs.Logout; if (AppContext.Current.AuthToken == null) { return(ResponseResult.Empty); } var result = await WebAPIClient.GetAsync(url, AppContext.Current.AuthToken); return(result); }
//destroyByIdPurchaseRequestAndIdProducer/{idPurchaseRequest}/{idProducer} //Servicio para eliminar la participación de un productor por IdPurchaseRequest y por IdProducer public static dynamic DestroySalesProcessesProducer(string token, dynamic parameters) { //POST var url = URL_VIRTUAL_FAIR_PURCHASEREQUESTPRODUCER; var urlMethod = "destroyByIdPurchaseRequestAndIdProducer"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", parameters.idPurchaseRequest, "/", parameters.idProducer); var response = clientAPI.HttpClient.DeleteAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//findByIdPurchaseRequestStatusInTwoNineAndExpirationDateGreatherThanNow public static dynamic FindByIdPurchaseRequestStatusInTwoNineAndExpirationDateGreatherThanNow(string token) { //GET var url = URL_VIRTUAL_FAIR_PURCHASEREQUESTPRODUCT; var urlMethod = "findByIdPurchaseRequestStatusInTwoNineAndExpirationDateGreatherThanNow"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = urlMethod; var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//Servicio para obtener una lista de todas las subasta de transporte que no estan publicadas public static dynamic GetFindByIsPublicEqualToZeroAdmin(string token) { //GET var url = URL_VIRTUAL_FAIR_TRANSPORTAUCTION; var urlMethod = "findByIsPublicEqualToZero"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = urlMethod; var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//findByIdCarrierAndIsPublicEqualToOne/{idCarrier //Servicio para obtener una lista de todas las subasta de transporte publicadas, la cual esta participando un transportista, por IdCarrier public static dynamic FindByIdCarrierAndIsPublicEqualToOne(string token, dynamic parameters) { //GET var url = URL_VIRTUAL_FAIR_TRANSPORTAUCTION; var urlMethod = "findByIdCarrierAndIsPublicEqualToOne"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", parameters.idCarrier); var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
public static dynamic FindAllStatus(string token) { //GET var url = URL_VIRTUAL_FAIR_PURCHASEREQUESTSTATUS; var urlMethod = "findAll"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = urlMethod; var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
public static dynamic FindByIdPurchaseRequest(string token, string idPurchaseRequest) { //GET var url = URL_VIRTUAL_FAIR_PURCHASEREQUESTPRODUCT; var urlMethod = "findByIdPurchaseRequest"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", idPurchaseRequest); var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
public static dynamic FindContractById(string token, dynamic contract) { //GET var url = URL_VIRTUAL_FAIR_CONTRACT; var urlMethod = "findById"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", contract.id); var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//Report/sendReportToParticipantsByIdPurchaseRequest/{idPurchaseRequest //Servicio para mandar reporte a todos los participantes por IdPurchaseRequest public static dynamic SendReportToParticipantsByIdPurchaseRequest(string token, dynamic parameters) { //GET var url = URL_VIRTUAL_FAIR_REPORT; var urlMethod = "sendReportToParticipantsByIdPurchaseRequest"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", parameters.idPurchaseRequest); var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//findByIdPurchaseRequestStatusInTwoNineAndUpdateDatePdf/{updateDateOf/{updateDateTo //Servicio para obtener archivo en base64 de reporte de las pérdidas por rango de fecha por la propiedad UpdateDate public static dynamic FindByIdPurchaseRequestStatusInTwoNineAndUpdateDatePdfConsultant(string token, dynamic parameters) { //GET var url = URL_VIRTUAL_FAIR_SUMMARYREPORT; var urlMethod = "findByIdPurchaseRequestStatusInTwoNineAndUpdateDatePdf"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", parameters.updateDateOf, "/", parameters.updateDateTo); var response = clientAPI.HttpClient.GetAsync(paramApi); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//create //Servicio para crear una participación de subasta de transporte public static dynamic CreateAuctionCarrier(string token, dynamic objectCreate) { //POST var url = URL_VIRTUAL_FAIR_TRANSPORTAUCTIONCARRIER; var urlMethod = "create"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = urlMethod; var content = JsonConvert.SerializeObject(objectCreate); var body = new StringContent(content, Encoding.UTF8, UtilWebApiMethod.TypeJson); var response = clientAPI.HttpClient.PostAsync(paramApi, body); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
//createBalancePurchaseRequest //Servicio para crear compra de saldo public static dynamic CreateBalancePurchaseRequest(string token, dynamic purchaseRequest) { //POST var url = URL_VIRTUAL_FAIR_PURCHASEREQUEST; var urlMethod = "createBalancePurchaseRequest"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = urlMethod; var content = JsonConvert.SerializeObject(purchaseRequest); var body = new StringContent(content, Encoding.UTF8, UtilWebApiMethod.TypeJson); var response = clientAPI.HttpClient.PostAsync(paramApi, body); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
public bool Init(LoggerOptions loggerOptions) { if (!m_bInitalized) { if (loggerOptions.OutputToFile) { m_swStreamWriter = new StreamWriter(new FileStream(loggerOptions.LogFile, FileMode.Create)); } if (loggerOptions.OutputToWebAPI) { m_WebAPIClient = new WebAPIClient(loggerOptions.WebAPIUrl); } m_loLoggerOptions = loggerOptions; m_bInitalized = true; return(true); } return(false); }
public static dynamic AdminUpdateIsPublicById(string token, dynamic objectUpdate) { //GET var url = URL_VIRTUAL_FAIR_PURCHASEREQUEST; var urlMethod = "updateIsPublicById"; WebAPIClient clientAPI = new WebAPIClient(url); //era necesario un Authorization clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", objectUpdate.id); var content = JsonConvert.SerializeObject(objectUpdate); var body = new StringContent(content, Encoding.UTF8, UtilWebApiMethod.TypeJson); var response = clientAPI.HttpClient.PutAsync(paramApi, body); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
public static dynamic CreateContract(string token, dynamic contract) { //POST var url = URL_VIRTUAL_FAIR_CONTRACT; var urlMethod = "create"; WebAPIClient clientAPI = new WebAPIClient(url); clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = urlMethod; var content = JsonConvert.SerializeObject(contract); var body = new StringContent(content, Encoding.UTF8, UtilWebApiMethod.TypeJson); var response = clientAPI.HttpClient.PostAsync(paramApi, body); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }
public static dynamic UserUpdateStatusById(string token, dynamic user) { //PUT var url = URL_VIRTUAL_FAIR_USER; var urlMethod = "updateStatusById"; WebAPIClient clientAPI = new WebAPIClient(url); clientAPI.HttpClient.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue(token); var paramApi = String.Concat(urlMethod, "/", user.id); var content = JsonConvert.SerializeObject(user); var body = new StringContent(content, Encoding.UTF8, UtilWebApiMethod.TypeJson); var response = clientAPI.HttpClient.PutAsync(paramApi, body); var result = clientAPI.Deserialize <dynamic>(response.Result); return(result); }