public ActionResult FilterSerial(SerialFilters filters)
        {
            try
            {
                var serials = _serialService.GetFilteredSerials(filters);
                ViewBag.SerialsReport = serials.Result.Items;

                ViewBag.Status = "";

                string result = "";
                if (filters.DocAction == "Create" && filters.Email != null && filters.Email != "")
                {
                    result = CreateSeriaDocument((List <SerialReport>)serials.Result.Items, filters.Email, filters.Interval).Result;
                }
                else if (filters.DocAction == "Update" && filters.Email != null && filters.Email != "")
                {
                    result = UpdateSeriaDocument((List <SerialReport>)serials.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 seriales");
            }
            return(View("Serial", filters));
        }
Example #2
0
            public static string GetFilteredSerials(string baseUri, SerialFilters filters)
            {
                var id = filters.Id != null ? filters.Id : 0;

                return($"{baseUri}/Summary?" +
                       $"id={id}" +
                       $"&serial={HttpUtility.UrlEncode(filters.Serial)}");
            }
        public ActionResult Serial()
        {
            var model = new SerialFilters();

            try
            {
                var serials = _serialService.GetFilteredSerials(model);
                ViewBag.SerialsReport = serials.Result.Items;
            }
            catch
            {
                throw new RequestErrorException("Error obteniendo los seriales");
            }
            return(View(model));
        }
Example #4
0
        public async Task <PaginatedList <SerialReport> > GetFilteredSerials(SerialFilters filters)
        {
            var uri      = API.Serial.GetFilteredSerials(_remoteServiceBaseUrl, filters);
            var response = await _httpClient.GetAsync(uri);

            if (response.StatusCode == System.Net.HttpStatusCode.InternalServerError)
            {
                throw new Exception("Error obteniendo los seriales");
            }

            response.EnsureSuccessStatusCode();
            var jsonResult = await response.Content.ReadAsStringAsync();

            var result = JsonConvert.DeserializeObject <PaginatedList <SerialReport> >(jsonResult);

            return(result);
        }