public async Task <UpdateCatalog> GetCatalog() { var result = new UpdateCatalog(); var sign = await GetOauth(); if (sign.IsAuthenticated) { var url = string.Format("api/v3/products?Token={0}", _config.GetToken()); _client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", sign.AccessToken); var response = await _client.GetAsync(url); result.Success = response.IsSuccessStatusCode; if (response.IsSuccessStatusCode) { var information = response.Content.ReadAsStringAsync().Result; result = JsonConvert.DeserializeObject <UpdateCatalog>(information, new JsonSerializerSettings { Culture = new CultureInfo("pt-BR") }); } else { var information = response.Content.ReadAsStringAsync().Result; result.Message = response.RequestMessage.ToString(); Log.Error("ERP - Buscar catálogo - Error: {Message}", result.Message); } } return(result); }
public object Put(UpdateCatalog request) { var entity = request.ConvertTo <Catalog>(); return(InTransaction(db => { Logic.Update(entity); return new CommonResponse(Logic.GetById(entity.Id)); })); }
public void UpdateCatalogStock(Dictionary <string, int> catalogItems) { if (catalogItems == null || catalogItems.Count == 0) { throw new Exception("Items cant be empty"); } foreach (var item in catalogItems) { if (CatalogItems.ContainsKey(item.Key)) { CatalogItems[item.Key] -= item.Value; } } var message = new UpdateCatalog() { Items = CatalogItems }; endpoint.Send(message).ConfigureAwait(false); }