public TicketPage(OauthResult oauth, LogisticType type = LogisticType.Interior, List <Ticket> tickets = null) { Oauth = oauth; Type = type; InitializeComponent(); InitTicket(oauth, type, tickets); }
private async Task SetLocalView(OauthResult oauth, LogisticType type, List <Ticket> tickets) { try { TicketsTable.Children.Clear(); if (tickets == null) { var hoy = DateTime.Now.AddDays(5).ToString("yyyy-MM-dd"); var pasado = DateTime.Now.AddDays(-15).ToString("yyyy-MM-dd"); Result = await App.RestClient.Get <TicketsResult>(App.BaseUrl + "/Ticket/OfLogistic", new Dictionary <string, object> { { "fechainicial", pasado }, { "fechafinal", hoy } }); if (Result != null && Result.Code == 100 && Result.Tickets != null && Result.Tickets.Count > 0) // mostramos las compras del usuario { tickets = Result.Tickets.OrderByDescending(e => e.Baucher).ToList(); SetTicketsLocalView(type, tickets, true); } else { await DisplayAlert(App.AppName, "No encontramos información para tu usuario, intente más tarde...", "Aceptar"); } } else { SetTicketsLocalView(type, tickets, false); } } catch { await DisplayAlert(App.AppName, "Verifica tu conexión a internet", "Aceptar"); } }
private async void InitTicket(OauthResult oauth, LogisticType type, List <Ticket> tickets) { if (oauth != null) { if (oauth.IdPerfil == 4) // cliente { if (ToolbarItems.Count == 0) { ToolbarItems.Add(new ToolbarItem { Text = "Refrescar", Order = ToolbarItemOrder.Primary, Priority = 1, Command = new Command(Refresh) }); } await SetClientView(oauth); } else if (oauth.IdPerfil == 1) // administrador { await SetAdminView(oauth, tickets); if (ToolbarItems.Count == 0) { ToolbarItems.Add(new ToolbarItem { Text = "Refrescar", Order = ToolbarItemOrder.Primary, Priority = 1, Command = new Command(Refresh) }); ToolbarItems.Add(new ToolbarItem { Text = "Buscar", Order = ToolbarItemOrder.Secondary, Priority = 0, Command = new Command(FindTicket) }); } } else if (oauth.IdPerfil == 2) // repartidor { if (ToolbarItems.Count == 0) { ToolbarItems.Add(new ToolbarItem { Text = "Refrescar", Order = ToolbarItemOrder.Primary, Priority = 1, Command = new Command(Refresh) }); ToolbarItems.Add(new ToolbarItem { Text = "Capital Federal", Order = ToolbarItemOrder.Secondary, Priority = 0, Command = new Command <LogisticType>(ChangePage), CommandParameter = LogisticType.Capital }); ToolbarItems.Add(new ToolbarItem { Text = "Interior", Order = ToolbarItemOrder.Secondary, Priority = 0, Command = new Command <LogisticType>(ChangePage), CommandParameter = LogisticType.Interior }); ToolbarItems.Add(new ToolbarItem { Text = "Buscar", Order = ToolbarItemOrder.Secondary, Priority = 0, Command = new Command(FindTicket) }); } await SetLocalView(oauth, type, tickets); } } }
public async Task <IHttpActionResult> GetSpotGoodsOrders(string openId, LogisticType logisticType) { var manager = new SpotGoodsManager(); Func <IQueryable <SpotGoodsOrder>, IQueryable <SpotGoodsOrder> > filter = query => { query = query.Where(r => r.OpenId == openId); if (logisticType == LogisticType.Self) { query = query.Where(r => r.SpotGoods.Status == SpotGoodsStatus.PickBySelf || r.SpotGoods.Status == SpotGoodsStatus.HasTaken); } if (logisticType == LogisticType.SF) { query = query.Where(r => r.SpotGoods.Status == SpotGoodsStatus.SF || r.SpotGoods.Status == SpotGoodsStatus.HasSendGoods); } return(query); }; var result = await manager.GetSpotGoodsOrderListAsync(filter); var orders = result.Select(r => new SpotGoodListItemViewModel(r)).ToList(); return(Ok(orders)); }
private void SetTicketsLocalView(LogisticType type, List <Ticket> tickets, bool filter = true) { TicketsTable.RowDefinitions.Add(new RowDefinition { Height = 40 }); Label pedido = new Label { Text = "Pedido" }; Label estatus = new Label { Text = "Estatus" }; Label monto = new Label { Text = "Monto" }; Label comprobante = new Label { Text = "Subir recibos" }; if (type == LogisticType.Interior) { monto.Text = "Transporte"; comprobante.Text = "Guia"; } else if (type == LogisticType.Capital) { comprobante.Text = "Cobrado"; } SetRowAndColumn(pedido, estatus, monto, comprobante, null, 0, null); int row = 1; foreach (var ticket in tickets) { string cliente = ""; if (ticket.Usuario != null) { cliente = ticket.Usuario.Nombre ?? ticket.Usuario.Correo; } pedido = new Label { Text = cliente }; pedido.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command <OauthResult>(InfoClient), CommandParameter = ticket.Usuario }); bool pagado = false; string state = "Sin pagar"; if (ticket.Baucher == null) { state = "Sin pagar"; } else if (ticket.Baucher != null && ticket.Verificado.Equals("0")) { state = "En revisión"; } else if (ticket.Baucher != null && ticket.Verificado.Equals("1") && ticket.Paqueteria == null) { pagado = true; state = "Pagado"; } else { pagado = true; state = "Pagado"; } estatus = new Label { Text = state }; var empresa = ticket.Direccion != null ? ticket.Direccion.Empresa ?? "Sin dirección" : "Sin dirección"; if (type == LogisticType.Interior) { monto = new Label { Text = empresa }; if (!empresa.Equals("Sin dirección")) { monto.GestureRecognizers.Add(new TapGestureRecognizer { Command = new Command <Ticket>(ShowDirection), CommandParameter = ticket }); } } else if (type == LogisticType.Capital) { monto = new Label { Text = "$" + ticket.Total }; } ticket.Pedido = pedido; ticket.Estatus = estatus; ticket.Monto = monto; if (type == LogisticType.Interior) { StackLayout layoutbuttons = new StackLayout { Orientation = StackOrientation.Horizontal }; Image camera = new Image { Source = "camera.png", WidthRequest = 25, HeightRequest = 25, Margin = new Thickness(5) }; bool enviado = false; if (ticket.Paqueteria == null) { if (pagado) { camera.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command <Ticket>(AddGuia), CommandParameter = ticket }); } else { camera.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command <Ticket>(WhitoutPayment), CommandParameter = ticket }); } } else { enviado = true; camera.Source = "document.png"; camera.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command <Ticket>(ViewPaqueteria), CommandParameter = ticket }); } ticket.BtnCamara = camera; layoutbuttons.Children.Add(camera); if (filter) { if (!enviado) { SetRowAndColumn(pedido, estatus, monto, null, layoutbuttons, row, ticket); row++; } } else { SetRowAndColumn(pedido, estatus, monto, null, layoutbuttons, row, ticket); row++; } } else if (type == LogisticType.Capital) { StackLayout layoutbuttons = new StackLayout { Orientation = StackOrientation.Horizontal }; if (!pagado) { Image camera = new Image { Source = "like.png", WidthRequest = 25, HeightRequest = 25, Margin = new Thickness(5) }; camera.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command <Ticket>(ConfirmarPago), CommandParameter = ticket }); ticket.BtnCamara = camera; layoutbuttons.Children.Add(camera); } if (!empresa.Equals("Sin dirección")) { Image direccion = new Image { Source = "map.png", WidthRequest = 25, HeightRequest = 25, Margin = new Thickness(5) }; direccion.GestureRecognizers.Add(new TapGestureRecognizer() { Command = new Command <Direction>(CheckAddress), CommandParameter = ticket.Direccion }); ticket.BtnDireccion = direccion; layoutbuttons.Children.Add(direccion); } if (filter) { if (!pagado) { SetRowAndColumn(pedido, estatus, monto, null, layoutbuttons, row, ticket); row++; } } else { SetRowAndColumn(pedido, estatus, monto, null, layoutbuttons, row, ticket); row++; } } } }
private async void ChangePage(LogisticType type) { await Navigation.PushAsync(new TicketPage(Oauth, type)); }