Beispiel #1
0
        private async Task <EmpresaModelContenedor> ObtenerEmpresasBase(RespuestaComun respuestaComun)
        {
            EmpresaModelContenedor empresaContenedor = new EmpresaModelContenedor();

            try
            {
                using (var client = new HttpClient())
                {
                    HttpResponseMessage response;
                    EmpresaModel        mEmpresa = new EmpresaModel();
                    mEmpresa.TipoAccion    = (int)Enumerador.EnumTipoAccion.Consultar;
                    mEmpresa.EstadoEmpresa = (int)Enumerador.EnumEstado.Activo;
                    response = await client.PostAsJsonAsync("http://localhost/FootControlRest/api/empresa/GestionarEmpresa", mEmpresa);

                    if (response.IsSuccessStatusCode)
                    {
                        empresaContenedor.LstEmpresaModel = await response.Content.ReadAsAsync <List <EmpresaModel> >();

                        empresaContenedor.Respuesta      = respuestaComun;
                        ViewBag.RespuestaErrorControlado = respuestaComun;
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorGenerico = string.Format(CultureInfo.CurrentCulture, Constantes.HTML_ERROR_GENERICO, Constantes.CODIGO_ERROR_GENERICO, Constantes.MENSAJE_ERROR_GENERICO, Constantes.MENSAJE_CONTACTO_ERROR_GENERICO);
                using (var client = new HttpClient())
                    await client.PostAsJsonAsync("http://localhost/FootControlRest/api/logs/GestionarLogException", Utilitariocs.PreparaGuardaLogsBase(ex));
            }
            return(empresaContenedor);
        }
Beispiel #2
0
        public async Task <ActionResult> Editar(string IdEmpresa)
        {
            EmpresaModelContenedor empresaContenedor = new EmpresaModelContenedor();
            EmpresaModel           empresaModel      = new EmpresaModel();
            int idEmpresaInput = int.Parse(IdEmpresa);

            try
            {
                using (var client = new HttpClient())
                {
                    HttpResponseMessage response;
                    EmpresaModel        mEmpresa = new EmpresaModel();
                    mEmpresa.TipoAccion    = (int)Enumerador.EnumTipoAccion.Consultar;
                    mEmpresa.IdEmpresa     = idEmpresaInput;
                    mEmpresa.EstadoEmpresa = (int)Enumerador.EnumEstado.Activo;
                    response = await client.PostAsJsonAsync("http://localhost/FootControlRest/api/empresa/GestionarEmpresa", mEmpresa);

                    if (response.IsSuccessStatusCode)
                    {
                        empresaContenedor.LstEmpresaModel = await response.Content.ReadAsAsync <List <EmpresaModel> >();

                        empresaModel            = empresaContenedor.LstEmpresaModel.FirstOrDefault(x => x.IdEmpresa == idEmpresaInput);
                        empresaModel.TipoAccion = (int)Enumerador.EnumTipoAccion.Actualizar;
                    }
                }
            }
            catch (Exception ex)
            {
                ViewBag.ErrorGenerico = string.Format(CultureInfo.CurrentCulture, Constantes.HTML_ERROR_GENERICO, Constantes.CODIGO_ERROR_GENERICO, Constantes.MENSAJE_ERROR_GENERICO, Constantes.MENSAJE_CONTACTO_ERROR_GENERICO);
                using (var client = new HttpClient())
                    await client.PostAsJsonAsync("http://localhost/FootControlRest/api/logs/GestionarLogException", Utilitariocs.PreparaGuardaLogsBase(ex));
            }
            return(View("GestionEmpresa", empresaModel));
        }
Beispiel #3
0
        public async Task <ActionResult> Empresa(RespuestaComun respuestaComun)
        {
            EmpresaModelContenedor empresaContenedor = await this.ObtenerEmpresasBase(respuestaComun);

            return(View(empresaContenedor.LstEmpresaModel));
            //return await Task.Run(() => View());
        }