public ActionResult FilterDispatch(DispatchFilters filters) { try { var dispatches = _dispatchService.GetFilteredDispatches(filters); ViewBag.DispatchesReport = dispatches.Result.Items; ViewBag.Status = ""; string result = ""; if (filters.DocAction == "Create" && filters.Email != null && filters.Email != "") { result = CreateDispatchDocument((List <DispatchReport>)dispatches.Result.Items, filters.Email, filters.Interval).Result; } else if (filters.DocAction == "Update" && filters.Email != null && filters.Email != "") { result = UpdateDispatchDocument((List <DispatchReport>)dispatches.Result.Items, filters.Email, filters.Interval).Result; } if (result == "OK") { ViewBag.Status = "El documento se ha enviado a " + filters.Email + ". " + "Puede tardar alrededor de un minuto en recibir el correo."; } } catch { throw new RequestErrorException("Error obteniendo los envíos"); } return(View("Dispatch", filters)); }
public async Task<PaginatedList<DispatchReport>> GetFilteredDispatches(DispatchFilters filters) { var uri = API.Dispatch.GetFilteredDispatches(_remoteServiceBaseUrl, filters); var response = await _httpClient.GetAsync(uri); if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError) { throw new Exception("Error obteniendo los envíos"); } response.EnsureSuccessStatusCode(); var jsonResult = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject<PaginatedList<DispatchReport>>(jsonResult); return result; }
public ActionResult Dispatch() { var model = new DispatchFilters(); try { var dispatches = _dispatchService.GetFilteredDispatches(model); ViewBag.DispatchesReport = dispatches.Result.Items; ViewBag.Status = ""; } catch { throw new RequestErrorException("Error obteniendo los envíos"); } return(View(model)); }
public static string GetFilteredDispatches(string baseUri, DispatchFilters filters) { var id = filters.Id != null ? filters.Id : 0; string from = filters.From.HasValue ? EscapeDataString(filters.From.Value.ToString("o")) : string.Empty; string to = filters.To.HasValue ? EscapeDataString(filters.To.Value.ToString("o")) : string.Empty; return($"{baseUri}/Summary?" + $"CreationDateFrom={from}" + $"&CreationDateTo={to}" + $"&id={id}" + $"&fid={HttpUtility.UrlEncode(filters.FID)}" + $"&destinationfid={HttpUtility.UrlEncode(filters.DestinationFID)}" + $"&transportmode={HttpUtility.UrlEncode(filters.TransportMode)}" + $"&vehicle={HttpUtility.UrlEncode(filters.Vehicle)}" + $"&destinationeu={filters.DestinationEU}"); }