Ejemplo n.º 1
0
        public async Task <IActionResult> BusquedaEdicionDetalle(MCDetCargaForDosBusquedaEdicionRequest request)
        {
            try
            {
                var detCargaActividadBus = new MCDetCargaForDosBus();


                string baseUrl = this.configuration.GetSection("AppSettings").GetSection("Servicio").Value;

                var response = await detCargaActividadBus.BusquedaEdicionDetalle(request, baseUrl);

                ViewData["ListaPrioridades"] = ListarValores_x_ICodParametro();
                ViewData["Trabajadores"]     = ListarTrabajadores_Carga(request.NumCarga, request.CodigoDetalle);

                if (response != null)
                {
                    if (response.IsSuccessStatusCode)
                    {
                        //string jsonResponse = await response.Content.ReadAsStringAsync();

                        //var detCargaActividadEdicion = JsonConvert.DeserializeObject<List<MCDetCargaForDosBusquedaEdicionResponse>>(jsonResponse);

                        var detCargaActividadEdicion = JsonConvert.DeserializeObject <MCDetCargaForDosBusquedaEdicionResponse>(response.Content.ReadAsStringAsync().Result);

                        return(View("EdicionAccion", detCargaActividadEdicion));
                    }
                    else
                    {
                        switch (response.StatusCode)
                        {
                        case HttpStatusCode.InternalServerError:
                            var mensajeErrorInterno = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        case HttpStatusCode.UnprocessableEntity:
                            var mensajeEntidadImprosesable = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        default:
                            Console.Write("Error");
                            break;
                        }
                    }
                }
                else
                {
                    Console.Write("Error");
                }
            }
            catch (Exception ex)
            {
                Console.Write("Error");
            }
            return(Content("Ups! Un error ocurrio"));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> BusquedaDetallesCarga(int numCarga)
        {
            try
            {
                MCDetCargaForDosListadoRequest detCargaActividadListadoRequest = new MCDetCargaForDosListadoRequest
                {
                    numCarga = numCarga
                };
                var detCargaActividadBus = new MCDetCargaForDosBus();

                string baseUrl = this.configuration.GetSection("AppSettings").GetSection("Servicio").Value;

                var response = await detCargaActividadBus.BusquedaDetalles(detCargaActividadListadoRequest, baseUrl);

                if (response != null)
                {
                    if (response.IsSuccessStatusCode)
                    {
                        ICollection <MCDetCargaForDosListadoResponse> detCargaActividadListado = JsonConvert.DeserializeObject <ICollection <MCDetCargaForDosListadoResponse> >(response.Content.ReadAsStringAsync().Result);
                        return(NewtonsoftJson(detCargaActividadListado));
                    }
                    else
                    {
                        switch (response.StatusCode)
                        {
                        case HttpStatusCode.InternalServerError:
                            var mensajeErrorInterno = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        case HttpStatusCode.UnprocessableEntity:
                            var mensajeEntidadImprosesable = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        default:
                            Console.Write("Error");
                            break;
                        }
                    }
                }
                else
                {
                    Console.Write("Error");
                }
            }
            catch (Exception ex)
            {
                Console.Write("Error");
            }
            return(Content("Ups! Un error ocurrio"));
        }
Ejemplo n.º 3
0
        public ResStringResponse ListarTrabajadores_Carga(int numCarga, int numDetCarga)
        {
            try
            {
                string baseUrl = configuration.GetSection("AppSettings").GetSection("Servicio").Value;

                var listadoResponseMessage = new MCDetCargaForDosBus().ListarTrabajadores_Carga(numCarga, numDetCarga, baseUrl);

                if (listadoResponseMessage != null)
                {
                    if (listadoResponseMessage.Result.IsSuccessStatusCode)
                    {
                        ResStringResponse respuesta = JsonConvert.DeserializeObject <ResStringResponse>(listadoResponseMessage.Result.Content.ReadAsStringAsync().Result);
                        return(respuesta);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Write("Error" + ex.Message);
            }
            return(null);
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> EdicionDetalle(MCDetCargaForDosEdicionRequest request)
        {
            try
            {
                var detCargaActividadBus = new MCDetCargaForDosBus();

                string baseUrl = this.configuration.GetSection("AppSettings").GetSection("Servicio").Value;

                var response = await detCargaActividadBus.EdicionDetalle(request, baseUrl);

                if (response != null)
                {
                    if (response.IsSuccessStatusCode)
                    {
                        var detCargaActividadEdicion = JsonConvert.DeserializeObject <MCDetCargaForDosEdicionResponse>(response.Content.ReadAsStringAsync().Result);

                        if (detCargaActividadEdicion.Exito)
                        {
                            ViewBag.MensajeExito = detCargaActividadEdicion.Mensaje;
                        }
                        else
                        {
                            ViewBag.MensajeError = detCargaActividadEdicion.Mensaje;
                        }

                        var detCargaActividadBusquedaEdicion = new MCDetCargaForDosBusquedaEdicionResponse
                        {
                            CodigoDetalle  = request.CodigoDetalle,
                            Ruc            = request.Ruc,
                            RazonSocial    = request.RazonSocial,
                            ZonaEspecifica = request.ZonaEspecifica,
                            Prioridad      = request.Prioridad,
                            PermisoInt     = request.PermisoInt
                        };

                        return(View("EdicionAccion", detCargaActividadBusquedaEdicion));
                    }
                    else
                    {
                        switch (response.StatusCode)
                        {
                        case HttpStatusCode.InternalServerError:
                            var mensajeErrorInterno = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        case HttpStatusCode.UnprocessableEntity:
                            var mensajeEntidadImprosesable = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        default:
                            Console.Write("Error");
                            break;
                        }
                    }
                }
                else
                {
                    Console.Write("Error");
                }
            }
            catch (Exception ex)
            {
                Console.Write("Error");
            }
            return(Content("Ups! Un error ocurrio"));
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> EdicionDetalle(MCDetCargaForDosEdicionRequest request)
        {
            try
            {
                var detCargaActividadBus = new MCDetCargaForDosBus();

                string baseUrl = this.configuration.GetSection("AppSettings").GetSection("Servicio").Value;

                var    IP       = Request.HttpContext.Connection.RemoteIpAddress;
                string compName = DetermineCompName(IP.ToString());

                if (request.Ruc == null)
                {
                    request.Ruc = " ";
                }


                request.NombreTerminal = compName;
                var response = await detCargaActividadBus.EdicionDetalle(request, baseUrl);

                if (response != null)
                {
                    if (response.IsSuccessStatusCode)
                    {
                        var detCargaActividadEdicion = JsonConvert.DeserializeObject <MCDetCargaForDosEdicionResponse>(response.Content.ReadAsStringAsync().Result);

                        if (detCargaActividadEdicion.Exito)
                        {
                            ViewBag.MensajeExito = detCargaActividadEdicion.Mensaje;
                        }
                        else
                        {
                            ViewBag.MensajeError = detCargaActividadEdicion.Mensaje;
                        }

                        var detCargaActividadBusquedaEdicion = new MCDetCargaForDosBusquedaEdicionResponse
                        {
                            NumCarga       = request.NumCarga,
                            CodigoDetalle  = request.CodigoDetalle,
                            Ruc            = request.Ruc,
                            RazonSocial    = request.RazonSocial,
                            ZonaEspecifica = request.ZonaEspecifica,
                            Prioridad      = request.Prioridad,
                            PermisoInt     = request.PermisoInt,
                            Trabajadores   = request.Trabajadores
                        };
                        ViewData["ListaPrioridades"] = ListarValores_x_ICodParametro();
                        ViewData["Trabajadores"]     = ListarTrabajadores_Carga(request.NumCarga, request.CodigoDetalle);
                        return(View("EdicionAccion", detCargaActividadBusquedaEdicion));
                    }
                    else
                    {
                        switch (response.StatusCode)
                        {
                        case HttpStatusCode.InternalServerError:
                            var mensajeErrorInterno = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        case HttpStatusCode.UnprocessableEntity:
                            var mensajeEntidadImprosesable = JsonConvert.DeserializeObject <ErrorInternoResponse>(response.Content.ReadAsStringAsync().Result);
                            Console.Write("Error");
                            break;

                        default:
                            Console.Write("Error");
                            break;
                        }
                    }
                }
                else
                {
                    Console.Write("Error");
                }
            }
            catch (Exception ex)
            {
                Console.Write("Error");
            }
            return(Content("Ups! Un error ocurrio"));
        }