コード例 #1
0
        // GET: api/Cliente
        public GenericResponse <IEnumerable <ClienteDto> > Get(int pagina = 1, int registros = 10, string Nombre = "")
        {
            GenericResponse <IEnumerable <ClienteDto> > response = new GenericResponse <IEnumerable <ClienteDto> >();

            try
            {
                IEnumerable <ClienteDto> data = servicio.Listar(Nombre);
                response = ResponseUtil.GetListaPaginada <ClienteDto>(data, pagina, registros);
            }
            catch (Exception ex)
            {
                throw new CustomResponseException(ex.Message, 500);
            }

            return(response);
        }
コード例 #2
0
        public GenericResponse <InfoPrincipalModel> InfoPrincipal()
        {
            GenericResponse <InfoPrincipalModel> response = new GenericResponse <InfoPrincipalModel>();
            JwtDecodeModel model = (JwtDecodeModel)Thread.CurrentPrincipal;

            try
            {
                bool esVendedor = false;

                esVendedor = model.Roles.Count() == 1 && model.IsInRole("Vendedor");


                ProductoServicio  prodServicio = new ProductoServicio();
                VentaServicio     ventServicio = new VentaServicio();
                ClienteServicio   cliServicio  = new ClienteServicio();
                PromocionServicio promServicio = new PromocionServicio();

                InfoPrincipalModel data = new InfoPrincipalModel();
                data.CantClientes   = cliServicio.Listar("").Count();
                data.CantProductos  = prodServicio.Listar("", 0).Count();
                data.CantVentas     = esVendedor ? ventServicio.Listar("", model.Id).Count() :  ventServicio.Listar("", 0).Count();
                data.CantUsuarios   = esVendedor ? 0 :  servicio.Listar("").Count();
                data.PromosActuales = promServicio.Listar("", 1);
                data.ProdBajoStock  = prodServicio.Listar("", 1);

                response.Data    = data;
                response.Codigo  = 200; // OK
                response.Error   = false;
                response.Mensaje = "OK";
            }
            catch (Exception ex)
            {
                throw new CustomResponseException(ex.Message, 500);
            }
            return(response);
        }