Exemplo n.º 1
0
        private async Task <ResultModel <IList <MemberModel> > > GetMembersInMailLists(IList <MailListModel> mailLists)
        {
            var mailListsIds = new List <int>();
            var list         = new List <MemberModel>();

            foreach (var mailList in mailLists)
            {
                if (int.TryParse(mailList.MailListID, out int mailListId))
                {
                    mailListsIds.Add(mailListId);
                }
            }

            int absolutePage   = 1;
            var continueSearch = true;

            while (continueSearch)
            {
                var filtroModel = new FiltroModel(mailListsIds, countDefault, absolutePage, null, "", null, null);
                var memberLists = await _memberModule.GetList(filtroModel);

                if (memberLists.Data.Count == 0)
                {
                    continueSearch = false;
                }
                else
                {
                    list.AddRange(memberLists.Data);
                }
                absolutePage++;
            }

            return(new SuccessResultModel <IList <MemberModel> >(list));
        }
Exemplo n.º 2
0
        public ActionResult Pesquisar(string txtFiltro, string optTipoFiltro)
        {
            ViewData["inputTxtFiltro"] = txtFiltro;

            var _tipoFiltro = new FiltroModel();

            ViewBag.optTipoFiltro = _tipoFiltro.Filtro(optTipoFiltro);

            if (txtFiltro != null && txtFiltro != "" && optTipoFiltro != "0")
            {
                IMapper mapper    = config.CreateMapper();
                var     registros = mapper.Map <IEnumerable <UnidadeFisica>, IEnumerable <UnidadeFisicaModel> >(_servicoUnidadeFisica.Listar(txtFiltro, optTipoFiltro));

                if (registros.Count() == 0)
                {
                    TempData.Add("Nulo", "Nenhum registro encontrado.");
                }
                return(View(registros));
            }
            else
            {
                var registros = new List <UnidadeFisicaModel>();
                return(View(registros));
            }
        }
 public IEnumerable <MovimientosModel> Listar <T>(FiltroModel filtro, int paginaActual, int personasPorPagina, Expression <Func <MovimientosModel, T> > ordenacion, Direccion direccion)
 {
     using (var c = new Contexto())
     {
         if (paginaActual < 1)
         {
             paginaActual = 1;
         }
         IQueryable <MovimientosModel> query = c.Movimiento;
         query = ListarFiltro(filtro, query);
         if (direccion == Direccion.Ascendente)
         {
             query = query.OrderBy(ordenacion);
         }
         else
         {
             query = query.OrderByDescending(ordenacion);
         }
         return(query.Skip((paginaActual - 1) * personasPorPagina)
                .Take(personasPorPagina)
                .Include(m => m.Cuenta)
                .Include(m => m.Categoria)
                .Include(m => m.SubCategoria)
                .ToList());
     }
 }
 public int ContarMovimientos(FiltroModel filtro)
 {
     using (var c = new Contexto())
     {
         IQueryable <MovimientosModel> query = c.Movimiento;
         query = ListarFiltro(filtro, query);
         return(query.Count());
     }
 }
 public int ContarTransacciones(FiltroModel filtro)
 {
     using (var c = new Contexto())
     {
         IQueryable <TransaccionModel> query = c.Transaccion;
         query = ListarFiltro(filtro, query);
         return(query.Count());
     }
 }
Exemplo n.º 6
0
        public async Task <ActionResult <IList <MailListModel> > > GetList([FromBody] FiltroModel filtroModel)
        {
            var operationResult = await _mailListModule.GetList(filtroModel);

            if (operationResult.Result != OperationResult.Ok)
            {
                return(BadRequest(operationResult));
            }

            return(Ok(operationResult));
        }
Exemplo n.º 7
0
        public async Task <ResultModel <IList <MailListModel> > > GetList(FiltroModel filtroModel = null)
        {
            var action = "list";

            try
            {
                using (HttpClient client = new HttpClient())
                {
                    var url = String.Format("{0}/{1}/{2}?{3}&{4}", _baseUri.GetURI(), _modulo, action,
                                            _baseUri.GetAPIKEY(), _baseUri.GetFormat());
                    if (filtroModel != null)
                    {
                        url += String.Format("&{0}", filtroModel.GetSearchQuery("MailListsIds"));
                    }
                    HttpResponseMessage response =
                        await client.GetAsync(url);

                    response.EnsureSuccessStatusCode();

                    string json = await response.Content.ReadAsStringAsync();

                    JObject rss = JObject.Parse(json);

                    try
                    {
                        JArray items = (JArray)rss["root"]["ajaxResponse"]["list"]["item"];

                        IList <MailListModel> models = new List <MailListModel>();
                        if (items != null)
                        {
                            foreach (var item in items.Children())
                            {
                                models.Add(item.ToObject <MailListModel>());
                            }
                            return(new SuccessResultModel <IList <MailListModel> >(models));
                        }
                        else
                        {
                            return(new ErrorResultModel <IList <MailListModel> >(
                                       "No se encontraron Listas de mails que coincidan con la búsqueda realizada"));
                        }
                    }
                    catch
                    {
                        JToken item = rss["root"]["ajaxResponse"]["errors"];
                        return(new ErrorResultModel <IList <MailListModel> >(item.ToString()));
                    }
                }
            }
            catch (Exception e)
            {
                return(new ErrorResultModel <IList <MailListModel> >(e.Message));
            }
        }
Exemplo n.º 8
0
        private async Task <ResultModel <IList <MailListModel> > > GetMailLists(string partialName)
        {
            if (partialName != null)
            {
                partialName.Trim();
            }

            var filtroModel = new FiltroModel(new List <int>(), countDefault, null, null, partialName, null, null);

            var mailLists = await _mailListModule.GetList(filtroModel);

            return(mailLists);
        }
Exemplo n.º 9
0
        public async Task <IEnumerable <ProdutoModel> > GetListByTermoAsync(FiltroModel filtroModel, string statusAtivacao)
        {
            IEnumerable <ProdutoModel> lista;

            lista = await _produtoRepository.GetFilterByTermoAsync(filtroModel.Termo, statusAtivacao);


            if (!lista.Any())
            {
                return(lista);
            }

            return(await FilterAndOrderListAsync(lista, filtroModel, statusAtivacao).ConfigureAwait(false));
        }
 public IQueryable <TransaccionModel> ListarFiltro(FiltroModel filtro, IQueryable <TransaccionModel> query)
 {
     if (filtro.FechaInicial != null)
     {
         query = query.Where(c => c.Fecha >= filtro.FechaInicial && c.Fecha <= filtro.FechaFinal);
     }
     if ((filtro.Filtro != "") && (filtro.Filtro != null))
     {
         query = query.Where(c => c.CuentaDestino.Nombre.Contains(filtro.Filtro) ||
                             c.CuentaOrigen.Nombre.Contains(filtro.Filtro) ||
                             c.Monto.ToString().Contains(filtro.Filtro) ||
                             c.Descripcion.Contains(filtro.Filtro));
     }
     return(query);
 }
        public IDictionary <string, double> ListarEgresoIngreso(FiltroModel filtro)
        {
            IDictionary <string, double> valores = new Dictionary <string, double>();

            using (var j = new Contexto())
            {
                IQueryable <MovimientosModel> query = j.Movimiento;
                query = ListarFiltro(filtro, query);

                List <MovimientosModel> query2 = query.ToList();
                valores.Add("ingreso", query2.Where(c => c.Tipo == true).Sum(s => s.Monto));
                valores.Add("egreso", query2.Where(c => c.Tipo == false).Sum(s => s.Monto));
            }
            return(valores);
        }
Exemplo n.º 12
0
        private async void Filtrar()
        {
            try
            {
                IsRunning = true;
                IsEnabled = false;

                Settings.FechaInicio    = FechaInicio.ToShortDateString();
                Settings.Sucursal       = SelectedSucursal == null ? "" : SelectedSucursal.Codigo;
                Settings.Viaje          = SelectedViaje == null ? "" : SelectedViaje.Codigo;
                Settings.NombreSucursal = SelectedSucursal == null ? "" : SelectedSucursal.Descripcion;
                Settings.NombreViaje    = SelectedViaje == null ? "" : SelectedViaje.Descripcion;
                IsRunning = false;
                IsEnabled = true;

                FiltroModel filtro = new FiltroModel
                {
                    Usuario     = Settings.IdUsuario,
                    Sucursal    = Settings.Sucursal,
                    Viaje       = Settings.Viaje,
                    Bodega      = Settings.Bodega,
                    Solicitante = Settings.Solicitante
                };
                var response_sinc = await apiService.Post <FiltroModel>(
                    Settings.UrlConexionActual,
                    Settings.RutaCarpeta,
                    "Filtro",
                    filtro);

                MainViewModel.GetInstance().JefeSupervisorOrdenes = new JefeSupervisorOrdenesViewModel();
                Application.Current.MainPage = new JefeSupervisorMasterPage();
            }

            catch (System.Exception ex)
            {
                this.IsEnabled = true;
                this.IsRunning = false;
                await Application.Current.MainPage.DisplayAlert(
                    "Alerta",
                    ex.Message,
                    "Aceptar");

                return;
            }
        }
Exemplo n.º 13
0
 public void POST([FromBody] FiltroModel value)
 {
     try
     {
         var Entity = db.TBCINV_FILTROS_APP.Where(q => q.USUARIO == value.USUARIO).FirstOrDefault();
         if (Entity == null)
         {
             db.TBCINV_FILTROS_APP.Add(new TBCINV_FILTROS_APP
             {
                 USUARIO     = value.USUARIO,
                 BARCO       = value.BARCO,
                 BODEGA      = value.BODEGA,
                 SOLICITANTE = value.SOLICITANTE,
                 VIAJE       = value.VIAJE
             });
         }
         else
         {
             Entity.BARCO       = value.BARCO;
             Entity.BODEGA      = value.BODEGA;
             Entity.VIAJE       = value.VIAJE;
             Entity.SOLICITANTE = value.SOLICITANTE;
         }
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         using (EntitiesGeneral Error = new EntitiesGeneral())
         {
             long ID = Error.APP_LOGERROR.Count() > 0 ? (Error.APP_LOGERROR.Select(q => q.SECUENCIA).Max() + 1) : 1;
             Error.APP_LOGERROR.Add(new APP_LOGERROR
             {
                 ERROR     = ex == null ? string.Empty : (ex.Message.Length > 1000 ? ex.Message.Substring(0, 1000) : ex.Message),
                 INNER     = ex.InnerException == null ? string.Empty : (ex.InnerException.Message.Length > 1000 ? ex.InnerException.Message.Substring(0, 1000) : ex.InnerException.Message),
                 FECHA     = DateTime.Now,
                 PROCESO   = "Filtro/POST",
                 SECUENCIA = ID
             });
             Error.SaveChanges();
         }
     }
 }
 public IQueryable <MovimientosModel> ListarFiltro(FiltroModel filtro, IQueryable <MovimientosModel> query)
 {
     if (filtro.FechaInicial != null)
     {
         query = query.Where(c => c.Fecha >= filtro.FechaInicial && c.Fecha <= filtro.FechaFinal);
     }
     if (filtro.Tipo != null)
     {
         query = query.Where(c => c.Tipo == filtro.Tipo);
     }
     if ((filtro.Filtro != "") && (filtro.Filtro != null))
     {
         query = query.Where(c => c.Categoria.Nombre.Contains(filtro.Filtro) ||
                             c.SubCategoria.Nombre.Contains(filtro.Filtro) ||
                             c.Cuenta.Nombre.Contains(filtro.Filtro) ||
                             c.Monto.ToString().Contains(filtro.Filtro) ||
                             c.HashTag.ToString().Contains(filtro.Filtro) ||
                             c.Descripcion.Contains(filtro.Filtro));
     }
     return(query);
 }
Exemplo n.º 15
0
        public async Task <IEnumerable <ProdutoModel> > GetListByCategoryAsync(FiltroModel filtroModel, string statusAtivacao)
        {
            IEnumerable <ProdutoModel> lista;

            if (filtroModel.Category == "offline")
            {
                lista = await _produtoRepository.GetOfflineProducts(statusAtivacao);
            }
            else
            {
                lista = await _produtoRepository.GetListByCategoryAsync(filtroModel.Category, 0, statusAtivacao);
            }


            if (!lista.Any())
            {
                return(lista);
            }

            return(await FilterAndOrderListAsync(lista, filtroModel, statusAtivacao).ConfigureAwait(false));
        }
Exemplo n.º 16
0
        private IEnumerable <ProdutoModel> Filter(IEnumerable <ProdutoModel> lista, FiltroModel filtroModel, string statusAtivacao)
        {
            List <ProdutoModel> listaFiltrada;

            var produtosModels = lista.ToList();

            if (filtroModel.CorOption > 0)
            {
                listaFiltrada = (from produtos in produtosModels
                                 join cor in _context.ProdutosCorModel on produtos.Id equals cor.ProdutoModelId
                                 where (filtroModel.MarcaOption == 0 || produtos.MarcaModelId == filtroModel.MarcaOption) &&
                                 (filtroModel.GeneroOption == null || produtos.Genero == filtroModel.GeneroOption) &&
                                 (filtroModel.MaterialOption == 0 || produtos.MaterialModelId == filtroModel.MaterialOption) &&
                                 cor.CorModelId == filtroModel.CorOption &&
                                 (statusAtivacao == null || produtos.StatusAtivacao == statusAtivacao)
                                 select new ProdutoModel(
                                     produtos.Id,
                                     produtos.MarcaModelId,
                                     produtos.MarcaModel,
                                     produtos.MaterialModelId,
                                     produtos.MaterialModel,
                                     produtos.Referencia,
                                     produtos.Tamanho,
                                     produtos.Descricao,
                                     produtos.ValorVenda,
                                     produtos.StatusProduto,
                                     produtos.Genero
                                     )).ToList();
            }
            else
            {
                listaFiltrada = produtosModels
                                .Where(x => (filtroModel.MarcaOption == 0 || x.MarcaModelId == filtroModel.MarcaOption) && (filtroModel.GeneroOption == null || x.Genero == filtroModel.GeneroOption) &&
                                       (filtroModel.MaterialOption == 0 || x.MaterialModelId == filtroModel.MaterialOption) && (statusAtivacao == null || x.StatusAtivacao == statusAtivacao)).ToList();
            }

            return(listaFiltrada);
        }
Exemplo n.º 17
0
        public FiltroModel GET(string USUARIO = "")
        {
            try
            {
                FiltroModel model = db.VW_FILTROS_APP.Where(q => q.USUARIO.ToLower() == USUARIO.ToLower()).Select(q => new FiltroModel
                {
                    USUARIO     = q.USUARIO,
                    BARCO       = q.BARCO,
                    VIAJE       = q.VIAJE,
                    SOLICITANTE = q.SOLICITANTE,
                    BODEGA      = q.BODEGA,

                    NOMBREBARCO       = q.NOMBREBARCO,
                    NOMBREBODEGA      = q.NOMBREBODEGA,
                    NOMBRESOLICITANTE = q.NOMBRESOLICITANTE,
                    NOMBREVIAJE       = q.NOMBREVIAJE
                }).FirstOrDefault();
                return(model ?? new FiltroModel());
            }
            catch (Exception ex)
            {
                using (EntitiesGeneral Error = new EntitiesGeneral())
                {
                    long ID = Error.APP_LOGERROR.Count() > 0 ? (Error.APP_LOGERROR.Select(q => q.SECUENCIA).Max() + 1) : 1;
                    Error.APP_LOGERROR.Add(new APP_LOGERROR
                    {
                        ERROR     = ex == null ? string.Empty : (ex.Message.Length > 1000 ? ex.Message.Substring(0, 1000) : ex.Message),
                        INNER     = ex.InnerException == null ? string.Empty : (ex.InnerException.Message.Length > 1000 ? ex.InnerException.Message.Substring(0, 1000) : ex.InnerException.Message),
                        FECHA     = DateTime.Now,
                        PROCESO   = "Filtro/GET",
                        SECUENCIA = ID
                    });
                    Error.SaveChanges();
                    return(new FiltroModel());
                }
            }
        }
Exemplo n.º 18
0
        public async Task <IEnumerable <ProdutoModel> > GetFilterAsync(IEnumerable <ProdutoModel> lista, FiltroModel filtroModel, string statusAtivacao)
        {
            var produtosModels = await lista.ToListAsync();

            if (produtosModels.Any())
            {
                return(await Filter(produtosModels, filtroModel, statusAtivacao).OrderBy(y => y.Referencia).ToListAsync());
            }

            return(await Filter(_context.ProdutosModel, filtroModel, statusAtivacao).OrderBy(y => y.Referencia).ToListAsync());
        }
Exemplo n.º 19
0
        public async Task <IEnumerable <ProdutoModel> > FilterAndOrderListAsync(IEnumerable <ProdutoModel> listaProdutos, FiltroModel filtroModel, string statusAtivacao)
        {
            IEnumerable <ProdutoModel> listaFiltradaOrdenada;

            var listaProdutosModels = listaProdutos.ToList();

            if (listaProdutosModels.Any())
            {
                listaFiltradaOrdenada = await _produtoRepository.GetFilterAsync(listaProdutosModels, filtroModel, statusAtivacao);
            }
            else
            {
                listaFiltradaOrdenada = await _produtoRepository.GetFilterAsync(new List <ProdutoModel>(), filtroModel, statusAtivacao);
            }



            if (filtroModel.OrderType != null)
            {
                return(await _produtoRepository.OrderListAsync(listaFiltradaOrdenada, filtroModel.OrderType));
            }

            return(listaFiltradaOrdenada);
        }
        private async void Guardar()
        {
            try
            {
                this.IsEnabled = false;
                this.IsRunning = true;
                if (string.IsNullOrEmpty(this.NombreBodega))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione la bodega",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NombreProveedor))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el proveedor",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NombreSucursal))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el barco",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NomViaje))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el viaje",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NombreSolicitante))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el solicitante",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.Comentario))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Ingrese el comentario",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.ValorOrden.ToString()))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Ingrese el valor de la orden",
                        "Aceptar");

                    return;
                }

                if (string.IsNullOrEmpty(this.Duracion.ToString()))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Ingrese la duración de la orden",
                        "Aceptar");

                    return;
                }

                Response con = await apiService.CheckConnection(Settings.UrlConexionActual);

                if (!con.IsSuccess)
                {
                    string UrlDistinto = Settings.UrlConexionActual == Settings.UrlConexionExterna ? Settings.UrlConexionInterna : Settings.UrlConexionExterna;
                    con = await apiService.CheckConnection(UrlDistinto);

                    if (!con.IsSuccess)
                    {
                        this.IsEnabled = true;
                        this.IsRunning = false;
                        await Application.Current.MainPage.DisplayAlert(
                            "Alerta",
                            con.Message,
                            "Aceptar");

                        return;
                    }
                    else
                    {
                        Settings.UrlConexionActual = UrlDistinto;
                    }
                }

                #region ValidacionProveedor
                var response_pro = await apiService.GetObject <ProveedorModel>(Settings.UrlConexionActual, Settings.RutaCarpeta, "Proveedor", "CODIGO=" + this.Orden.IdProveedor);

                if (!response_pro.IsSuccess)
                {
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        response_pro.Message,
                        "Aceptar");

                    return;
                }
                var proveedor = (ProveedorModel)response_pro.Result;
                if (proveedor == null || string.IsNullOrEmpty(proveedor.Codigo))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "El proveedor seleccionado no existe.",
                        "Aceptar");

                    return;
                }
                decimal DuracionAcumulada = (proveedor.DuracionAcumulada == null ? 0 : Convert.ToDecimal(proveedor.DuracionAcumulada));
                if (proveedor.Duracion > 0 && proveedor.Duracion < (DuracionAcumulada + Duracion))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Ha superado la duración en días que el proveedor puede ser contratado {" + proveedor.Duracion + "} para órdenes de globales de la compañía.",
                        "Aceptar");

                    return;
                }
                #endregion

                this.Orden.Usuario       = Settings.IdUsuario;
                this.Orden.Comentario    = Comentario;
                this.Orden.Fecha         = Fecha;
                this.Orden.Valor         = Valor.ToString();
                this.Orden.ValorIva      = ValorIva.ToString();
                this.Orden.TipoDocumento = TipoSelectedIndex == "Orden de trabajo" ? "OT" : "OK";
                this.Orden.Duracion      = Duracion;



                var response_sinc = await apiService.Post <OrdenModel>(
                    Settings.UrlConexionActual,
                    Settings.RutaCarpeta,
                    "CreacionOrdenTrabajo",
                    this.Orden);

                if (!response_sinc.IsSuccess)
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        response_sinc.Message,
                        "Aceptar");

                    return;
                }

                #region Actualizo filtros
                Settings.Solicitante = this.Orden.IdSolicitante;
                Settings.Bodega      = this.Orden.IdBodega;
                Settings.Viaje       = this.Orden.IdViaje;
                Settings.Sucursal    = this.Orden.IdSucursal;

                Settings.NombreViaje       = this.Orden.NomViaje;
                Settings.NombreSucursal    = this.Orden.NomCentroCosto;
                Settings.NombreSolicitante = this.Orden.NombreSolicitante;
                Settings.NombreBodega      = this.Orden.NombreBodega;


                FiltroModel filtro = new FiltroModel
                {
                    Usuario     = Settings.IdUsuario,
                    Sucursal    = Settings.Sucursal,
                    Viaje       = Settings.Viaje,
                    Bodega      = Settings.Bodega,
                    Solicitante = Settings.Solicitante
                };


                var response_fil = await apiService.Post <FiltroModel>(
                    Settings.UrlConexionActual,
                    Settings.RutaCarpeta,
                    "Filtro",
                    filtro);

                #endregion


                await Application.Current.MainPage.DisplayAlert(
                    "Alerta",
                    Orden.NumeroOrden > 0? "Se ha modificado la orden exitósamente" : "Se ha creado la orden exitósamente",
                    "Aceptar");



                MainViewModel.GetInstance().MisOrdenesTrabajo.LoadLista();
                await App.Navigator.Navigation.PopAsync();
            }
            catch (System.Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Alerta",
                    ex.Message,
                    "Aceptar");

                return;
            }
        }
        // GET: Movimientos
        public ActionResult Index(int page = 1, string sort = "Fecha", string sortDir = "DESC", FiltroModel oFiltro = null)
        {
            int NumeroDePersonas = db.ContarMovimientos(oFiltro);
            IEnumerable <MovimientosModel> mov;
            Direccion dir = sortDir.Equals("ASC", StringComparison.CurrentCultureIgnoreCase) ?
                            Direccion.Ascendente :
                            Direccion.Descendente;

            switch (sort.ToLower())
            {
            case "Fecha":
                mov = db.Listar(oFiltro, page, 10, p => p.Fecha, dir);
                break;

            case "Tipo":
                mov = db.Listar(oFiltro, page, 10, p => p.Tipo, dir);
                break;

            case "Categoria":
                mov = db.Listar(oFiltro, page, 10, p => p.Categoria.Nombre, dir);
                break;

            case "SubCategoria":
                mov = db.Listar(oFiltro, page, 10, p => p.SubCategoria.Nombre, dir);
                break;

            case "Cuenta":
                mov = db.Listar(oFiltro, page, 10, p => p.Cuenta.Nombre, dir);
                break;

            case "Descripcion":
                mov = db.Listar(oFiltro, page, 10, p => p.Descripcion, dir);
                break;

            case "Monto":
                mov = db.Listar(oFiltro, page, 10, p => p.Monto, dir);
                break;

            default:
                mov = db.Listar(oFiltro, page, 10, p => p.Fecha, dir);
                break;
            }

            MovimientosViewModel oViewModel = new MovimientosViewModel()
            {
                filtro = oFiltro, Movimientos = mov, NumeroDePersonas = NumeroDePersonas, PersonasPorPagina = 10, valores = db.ListarEgresoIngreso(oFiltro)
            };

            ViewBag.Menu = GeneraMenu();
            return(View(oViewModel));
        }
 public TransaccionesViewModel()
 {
     Transaccion = new List <TransaccionModel>();
     filtro      = new FiltroModel();
 }
        private async void Guardar()
        {
            try
            {
                this.IsEnabled = false;
                this.IsRunning = true;
                if (string.IsNullOrEmpty(this.NombreBodega))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione la bodega",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NombreSucursal))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el barco",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NomViaje))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el viaje",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.NombreSolicitante))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Seleccione el solicitante",
                        "Aceptar");

                    return;
                }
                if (string.IsNullOrEmpty(this.Comentario))
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        "Ingrese el comentario",
                        "Aceptar");

                    return;
                }

                Response con = await apiService.CheckConnection(Settings.UrlConexionActual);

                if (!con.IsSuccess)
                {
                    string UrlDistinto = Settings.UrlConexionActual == Settings.UrlConexionExterna ? Settings.UrlConexionInterna : Settings.UrlConexionExterna;
                    con = await apiService.CheckConnection(UrlDistinto);

                    if (!con.IsSuccess)
                    {
                        this.IsEnabled = true;
                        this.IsRunning = false;
                        await Application.Current.MainPage.DisplayAlert(
                            "Alerta",
                            con.Message,
                            "Aceptar");

                        return;
                    }
                    else
                    {
                        Settings.UrlConexionActual = UrlDistinto;
                    }
                }

                this.Orden.Usuario     = Settings.IdUsuario;
                this.Orden.Observacion = Comentario;
                this.Orden.Fecha       = Fecha;
                this.Orden.LstDet      = new System.Collections.Generic.List <PedidoDetModel>();

                var response_sinc = await apiService.Post <PedidoModel>(
                    Settings.UrlConexionActual,
                    Settings.RutaCarpeta,
                    "Pedidos",
                    this.Orden);

                if (!response_sinc.IsSuccess)
                {
                    this.IsEnabled = true;
                    this.IsRunning = false;
                    await Application.Current.MainPage.DisplayAlert(
                        "Alerta",
                        response_sinc.Message,
                        "Aceptar");

                    return;
                }

                #region Actualizo filtros
                Settings.Solicitante = this.Orden.IdSolicitante;
                Settings.Bodega      = this.Orden.IdBodega;
                Settings.Viaje       = this.Orden.IdViaje;
                Settings.Sucursal    = this.Orden.IdSucursal;

                Settings.NombreViaje       = this.Orden.NombreViaje;
                Settings.NombreSucursal    = this.Orden.NombreSucursal;
                Settings.NombreSolicitante = this.Orden.NombreEmpleado;
                Settings.NombreBodega      = this.Orden.NombreBodega;

                FiltroModel filtro = new FiltroModel
                {
                    Usuario     = Settings.IdUsuario,
                    Sucursal    = Settings.Sucursal,
                    Viaje       = Settings.Viaje,
                    Bodega      = Settings.Bodega,
                    Solicitante = Settings.Solicitante
                };
                var response_fil = await apiService.Post <FiltroModel>(
                    Settings.UrlConexionActual,
                    Settings.RutaCarpeta,
                    "Filtro",
                    filtro);

                #endregion

                await Application.Current.MainPage.DisplayAlert(
                    "Alerta",
                    Orden.ID > 0? "Se ha modificado el pedido exitósamente" : "Se ha creado el pedido exitósamente",
                    "Aceptar");

                MainViewModel.GetInstance().MisPedidos.LoadLista();
                await App.Navigator.Navigation.PopAsync();
            }
            catch (System.Exception ex)
            {
                await Application.Current.MainPage.DisplayAlert(
                    "Alerta",
                    ex.Message,
                    "Aceptar");

                return;
            }
        }
Exemplo n.º 24
0
        // GET: Transaccion
        public ActionResult Index(int page = 0, string sort = "Fecha", string sortDir = "DESC", FiltroModel oFiltro = null)
        {
            int NumeroDePersonas = _repository.ContarTransacciones(oFiltro);
            IEnumerable <TransaccionModel> trans;
            Direccion dir = sortDir.Equals("ASC", StringComparison.CurrentCultureIgnoreCase) ?
                            Direccion.Ascendente :
                            Direccion.Descendente;

            switch (sort.ToLower())
            {
            case "Fecha":
                trans = _repository.Listar(oFiltro, page, 10, p => p.Fecha, dir);
                break;

            case "CuentaOrigen":
                trans = _repository.Listar(oFiltro, page, 10, p => p.CuentaOrigen.Nombre, dir);
                break;

            case "CuentaDestino":
                trans = _repository.Listar(oFiltro, page, 10, p => p.CuentaDestino.Nombre, dir);
                break;

            case "Descripcion":
                trans = _repository.Listar(oFiltro, page, 10, p => p.Descripcion, dir);
                break;

            case "Monto":
                trans = _repository.Listar(oFiltro, page, 10, p => p.Monto, dir);
                break;

            default:
                trans = _repository.Listar(oFiltro, page, 10, p => p.Fecha, dir);
                break;
            }

            TransaccionesViewModel oViewModel = new TransaccionesViewModel()
            {
                filtro = oFiltro, Transaccion = trans, NumeroDePersonas = NumeroDePersonas, PersonasPorPagina = 10
            };

            ViewBag.Menu = GeneraMenu();
            return(View(oViewModel));
        }
 public MovimientosViewModel()
 {
     Movimientos = new List <MovimientosModel>();
     filtro      = new FiltroModel();
     valores     = new Dictionary <string, double>();
 }