public PedidoCore(PedidoView pedido, IMapper mapper) { //Ler arquivo Db = file.ManipulacaoDeArquivos(null).sistema; //Caso arquivo não existe Db = Db ?? new Sistema(); //Intanciando o mapper Mapper = mapper; RPedido = Mapper.Map <Pedido>(pedido); //Preenchendo informações do cliente RPedido._cliente = Mapper.Map <Cliente>(Db.Clientes.SingleOrDefault(temp => temp.Id == RPedido._cliente.Id)); //Preenchendo informações dos produtos RPedido.Compras.ForEach(c => c.Copiar(Db.Produtos.SingleOrDefault(temp => temp.Id == c.Id))); RuleFor(e => e._cliente) .NotNull() .NotEmpty() .WithMessage("Cliente não existe na base de dados"); RuleFor(e => e.Compras) .NotNull() .NotEmpty() .ForEach(e => e.Must(ValidaLista).WithMessage("O produto nâo existe na base de dados ou Quantidade ultrapassa o estoque")); RuleForEach(e => e.Compras) .Must(p => p.Quantidade > 0) .WithMessage("Quantidade Invalida"); }
public async Task <IActionResult> Pedido(Guid id) { var pedido = new PedidoView(); var item = new ItemView(); using (var httpClient = new HttpClient()) { var url = _configuration["UrlAPICliente:UrlBase"] + $"/Items/{id}"; using (var resposta = await httpClient.GetAsync(url)) { string apiResposta = await resposta.Content.ReadAsStringAsync(); item = JsonConvert.DeserializeObject <ItemView>(apiResposta); } var b = _contextAccessor.HttpContext.User.Identity.Name; var user = _context.Users.FirstOrDefault(u => u.UserName == b); if (_contextAccessor.HttpContext.User.Identity.IsAuthenticated) { pedido.Cliente = Guid.Parse(user.Id); } pedido.Item = item; pedido.Valor = item.Valor; pedido.Restaurante = item.RestauranteId; TempData["pedido"] = JsonConvert.SerializeObject(pedido); if (!ValidarUsuarioNaAPI(Guid.Parse(user.Id)).Result) { return(RedirectToAction("Index", "Cadastro")); } return(RedirectToAction("Pedido", "Pedidos")); } }
public ActionResult NuevoPedido(PedidoView pedidoView) { pedidoView = Session["PedidoView"] as PedidoView; var id = int.Parse(Request["idcliente"]); DateTime dateEjecucion = Convert.ToDateTime(Request["FechaPedido"]); string costo = Request["Costo"]; Pedido pedido = new Pedido { fechaEjecucion = dateEjecucion, idcliente = id, costo = Convert.ToDecimal(costo) }; PedidoBLL.Create(pedido); int ultimoPedido = PedidoBLL.List().Select(x => x.idpedido).Max(); foreach (Servicio item in pedidoView.Servicios) { var detalle = new DetallePedido() { idpedido = ultimoPedido, idservicio = item.idservicio }; DetallePedidoBLL.Create(detalle); } pedidoView = Session["PedidoView"] as PedidoView; ViewBag.idcliente = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre"); return(RedirectToAction("Index")); }
public async Task <ActionResult <PedidoView> > PostPedido(PedidoView pedido) { var p = new Pedido() { Restaurante = await _res.BuscarAsync(pedido.Restaurante), Cliente = await _cli.BuscarAsync(pedido.Cliente), Status = "Pendente", Observacao = pedido.Observacao, Valor = pedido.Valor, Pagamento = pedido.Pagamento, }; var l = new List <ItemPedido>(); var ip = new ItemPedido { ItemId = pedido.Item.Id }; l.Add(ip); try { p.Itens = l; } catch (Exception e) { throw e; } var resultado = await _service.AdicionarAsync(p); return(CreatedAtAction("GetPedido", new { id = resultado.Id })); }
private void btn_pedidos_Click(object sender, EventArgs e) { PedidoView p = new PedidoView(); p.Show(); this.Hide(); }
// GET: DetallePedido public ActionResult NuevoPedido() { PedidoView pv = new PedidoView(); pv.Cliente = new Cliente(); pv.Servicios = new List <Servicio>(); pv.Costo = "0.00"; Session["PedidoView"] = pv; ViewBag.idcliente = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre"); return(View(pv)); }
public IActionResult Pedido() { var e = new PedidoView(); if (TempData["pedido"] != null) { e = JsonConvert.DeserializeObject <PedidoView>((string)TempData["pedido"]); } return(View(e)); }
public ActionResult NuevoPedido() { PedidoView pedidoView = new PedidoView(); pedidoView.Cliente = new Cliente(); pedidoView.ProductosPedidos = new List <ProductoPedido>(); Session["PedidoView"] = pedidoView; var listaClientes = db.Clientes.ToList(); ViewBag.ClienteId = new SelectList(listaClientes, "ClienteId", "ClienteRazonSocial"); return(View(pedidoView)); }
public async Task <IActionResult> Index(Guid id) { var pedido = new PedidoView(); using (var httpClient = new HttpClient()) { var url = _configuration["UrlAPICliente:UrlBase"] + $"/Pedidos/{id}"; using var resposta = await httpClient.GetAsync(url); string apiResposta = await resposta.Content.ReadAsStringAsync(); pedido = JsonConvert.DeserializeObject <PedidoView>(apiResposta); } return(View(pedido)); }
public ActionResult NuevoPedido(PedidoView pedidoView, Entretenimiento entretenimiento) { pedidoView = Session["PedidoView"] as PedidoView; int idCliente = int.Parse(Request["ClienteId"]); Pedido pedido = new Pedido() { ClienteId = idCliente, PedidoFecha = DateTime.Now, total = pedidoView.total }; // LIsto Cabecera db.Pedidoes.Add(pedido); int ultimoPedido = db.Pedidoes.ToList().Select(p => p.PedidoId).Max(); foreach (EntretenimientoPedido item in pedidoView.Entretenimientos) { var detalle = new PedidoDetalle() { PedidoId = ultimoPedido + 1, IdEntrete = item.IdEntrete, PrecioVenta = item.PrecioVent, PrecioAlquiler = item.Precio, Cantidad = 1 }; db.PedidoDetalles.Add(detalle); //var listaEntre = from u in db.Entretenimientoes // where u.CatPelicula.NombreGenero == genero // select u; //Entretenimiento entre = new Entretenimiento() //{ // Stock = pedidoView.Entretenimiento.Stock //}; //db.Entretenimientoes.Add(entre); } db.SaveChanges(); pedidoView = Session["PedidoView"] as PedidoView; var listaClientes = db.Clientes.ToList(); ViewBag.ClienteId = new SelectList(listaClientes, "ClienteId", "NombreCliente"); return(View(pedidoView)); }
public static PedidoView PedidoToPedidoView(PedidoView pView, Pedido pedido) { pView.Id = pedido.Id; pView.Valor = pedido.Valor; pView.Observacao = pedido.Observacao; pView.Restaurante = pedido.Restaurante.Id; pView.Cliente = pedido.Cliente.Id; pView.Status = pedido.Status; pView.Pagamento = pedido.Pagamento; foreach (var i in pedido.Itens) { pView.Item = ItemToItemView(new ItemView(), i.Item); } return(pView); }
public ActionResult NuevoPedido(PedidoView pedidoView) { pedidoView = Session["PedidoView"] as PedidoView; int idCliente = int.Parse(Request["ClienteId"]); Pedido pedido = new Pedido() { ClienteId = idCliente, PedidoFecha = DateTime.Now }; db.Pedidoes.Add(pedido); db.SaveChanges(); int ultimoPedidoId = db.Pedidoes.ToList() .Select(p => p.PedidoId).Max(); foreach (ProductoPedido item in pedidoView.ProductosPedidos) { var detalle = new PedidoDetalle() { PedidoId = ultimoPedidoId, ProductoId = item.ProductoId, Cantidad = item.Cantidad }; db.PedidoDetalles.Add(detalle); } db.SaveChanges(); pedidoView = Session["PedidoView"] as PedidoView; var listaClientes = db.Clientes.ToList(); ViewBag.ClienteId = new SelectList(listaClientes, "ClienteId", "ClienteRazonSocial"); return(View(pedidoView)); }
static void Main(string[] args) { MenuView menu = new MenuView(); menu.ExibirMenu(); Pedido pedido = new Pedido(); ClienteService clienteService = new ClienteService(); clienteService.RegistrarCliente(pedido); PedidoService pedidoService = new PedidoService(); pedidoService.RegistrarItensDoPedido(pedido); double total = pedidoService.CalcularTotalPedido(pedido); Console.WriteLine("Total: " + total); PedidoView.ResumoPedido(pedido); }
public async Task <IActionResult> ConfirmarPedido([FromForm] string restaurante, string cliente, string valor, string item, string pagamento, string observacao) { var pedido = new PedidoView() { Restaurante = Guid.Parse(restaurante), Cliente = Guid.Parse(cliente), Valor = Decimal.Parse(valor), Pagamento = Enum.Parse <FormaPagamento>(pagamento, true), Observacao = observacao, }; using (var httpClient = new HttpClient()) { var url = _configuration["UrlAPICliente:UrlBase"] + $"/Items/{item}"; using var resposta = await httpClient.GetAsync(url); string apiResposta = await resposta.Content.ReadAsStringAsync(); pedido.Item = JsonConvert.DeserializeObject <ItemView>(apiResposta); } StringContent content = new StringContent(JsonConvert.SerializeObject(pedido), Encoding.UTF8, "application/json"); using (var httpClient = new HttpClient()) { var url = _configuration["UrlAPICliente:UrlBase"] + $"/Pedidos"; using var resposta = await httpClient.PostAsync(url, content); //string apiResposta = await resposta.Content.ReadAsStringAsync(); //item = JsonConvert.DeserializeObject<PedidoView>(apiResposta); //TempData["pedido"] = JsonConvert.SerializeObject(pedido); } return(RedirectToAction(nameof(Listar))); }
public async Task <IActionResult> Post([FromBody] PedidoView pedido) { var cadastro = new PedidoCore(pedido, Mapper).CadastroPedido(); return(cadastro.Status ? Created($"https://localhost/api/pedidos/{cadastro.Resultado.Id}", cadastro.Resultado) : BadRequest(cadastro.Resultado)); }
private void Pedidos_Click(object sender, RoutedEventArgs e) { PedidoView ped = new PedidoView(); ped.ShowDialog(); }
public void inicializarComponente() { _TituloLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.TITULO1], HorizontalTextAlignment = TextAlignment.Center }; _enderecoView = new EnderecoView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, }; _enderecoView.SetBinding(EnderecoView.BindingContextProperty, new Binding(".")); _MetodoEntregaLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO], LineBreakMode = LineBreakMode.TailTruncation }; _MetodoEntregaLabel.SetBinding(Label.TextProperty, new Binding("EntregaStr")); _FormaPagamentoLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO], LineBreakMode = LineBreakMode.TailTruncation }; _FormaPagamentoLabel.SetBinding(Label.TextProperty, new Binding("PagamentoStr")); _TrocoParaLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _TrocoParaLabel.SetBinding(Label.TextProperty, new Binding("TrocoParaStr", stringFormat: "R${0}")); _ValorFreteLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _ValorFreteLabel.SetBinding(Label.TextProperty, new Binding("ValorFreteStr", stringFormat: "R${0}")); _ValorTotalLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _ValorTotalLabel.SetBinding(Label.TextProperty, new Binding("TotalStr", stringFormat: "R${0}")); _SituacaoLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, LineBreakMode = LineBreakMode.TailTruncation, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _SituacaoLabel.SetBinding(Label.TextProperty, new Binding("SituacaoStr")); _diaEntregaLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _diaEntregaLabel.SetBinding(Label.TextProperty, new Binding("DiaEntregaStr")); _horarioEntregaLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _horarioEntregaLabel.SetBinding(Label.TextProperty, new Binding("HorarioEntrega")); _mensagemRetiradaLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _mensagemRetiradaLabel.SetBinding(Label.TextProperty, new Binding("Loja.MensagemRetirada")); _ObservacaoLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.LABEL_CAMPO] }; _ObservacaoLabel.SetBinding(Label.TextProperty, new Binding("Observacao")); _PedidoView = new PedidoView { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, }; _PedidoView.SetBinding(PedidoView.BindingContextProperty, new Binding(".")); _ImprimirButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.BTN_PRINCIPAL], Text = "Imprimir Boleto" }; _ImprimirButton.Clicked += async(sender, e) => { if (Pedido.Pagamento == null && !Pedido.IdPagamento.HasValue) { //UserDialogs.Instance.Alert("Pedido não possui pagamento vinculado.", "Erro", "Fechar"); await DisplayAlert("Erro", "Pedido não possui pagamento vinculado.", "Entendi"); return; } if (Pedido.Pagamento == null) { UserDialogs.Instance.ShowLoading("Carregando..."); try { var regraPagamento = PagamentoFactory.create(); var pagamento = await regraPagamento.pegar(Pedido.IdPagamento.Value); UserDialogs.Instance.HideLoading(); Pedido.Pagamento = pagamento; } catch (Exception erro) { UserDialogs.Instance.HideLoading(); //UserDialogs.Instance.Alert(erro.Message, "Erro", "Fechar"); await DisplayAlert("Erro", erro.Message, "Entendi"); } } var boletoImprimePage = new BoletoImprimePage { Pagamento = Pedido.Pagamento }; await Navigation.PushAsync(boletoImprimePage); }; _AcompanhaButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.BTN_SUCESSO], Text = "Acompanhar no Mapa" }; _AcompanhaButton.Clicked += acompanharClicked; _CancelarButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.BTN_DANGER], Text = "Cancelar" }; _CancelarButton.Clicked += cancelarClicked; _AvaliarButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.BTN_SUCESSO], Text = "Avaliar" }; _AvaliarButton.Clicked += avaliarClicked; _horarioButton = new Button { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, Style = Estilo.Current[Estilo.BTN_SUCESSO], Text = "Definir horário de entrega" }; _horarioButton.Clicked += horarioClicked; _empresaLabel = new Label { HorizontalOptions = LayoutOptions.Fill, VerticalOptions = LayoutOptions.Start, HorizontalTextAlignment = TextAlignment.Center, FontAttributes = FontAttributes.Bold, Margin = new Thickness(0, 0, 0, 3), Text = "Smart Tecnologia ®" }; _empresaLabel.SetBinding(Label.TextProperty, new Binding("Loja.Nome")); _rodapeLayout = new StackLayout { Orientation = StackOrientation.Vertical, VerticalOptions = LayoutOptions.End, HorizontalOptions = LayoutOptions.Fill, Margin = new Thickness(5, 0), Spacing = 0, Children = { new Label { VerticalOptions = LayoutOptions.Start, HorizontalOptions = LayoutOptions.Fill, HorizontalTextAlignment = TextAlignment.Center, Text = "Esse pedido foi feito em:", FontSize = 10 }, _empresaLabel } }; }
public ActionResult NuevoPedido(int?id, int?c, EntretenimientoPedido entrepedido) { if (id == null) { PedidoView pedidoView = new PedidoView(); pedidoView.Cliente = new Cliente(); pedidoView.Entretenimientos = new List <EntretenimientoPedido>(); Session["PedidoView"] = pedidoView; var listaClientes = db.Clientes.ToList(); ViewBag.ClienteId = new SelectList(listaClientes, "ClienteId", "NombreCliente"); return(View(pedidoView)); } //postagregar if (c == 1) { var pedidoView = Session["PedidoView"] as PedidoView; var entre = db.Entretenimientoes.Find(id); entrepedido = new EntretenimientoPedido() { IdEntrete = entre.IdEntrete, Nombre = entre.Nombre, PrecioVent = entre.PrecioVent }; pedidoView.Entretenimientos.Add(entrepedido); Entretenimiento entret = new Entretenimiento() { Stock = entre.Stock - 1 }; db.Entretenimientoes.Add(entret); var listaClientes = db.Clientes.ToList(); ViewBag.ClienteId = new SelectList(listaClientes, "ClienteId", "NombreCliente"); var listaEntre = db.Entretenimientoes.ToList(); ViewBag.IdEntrete = new SelectList(listaEntre, "IdEntrete", "Nombre"); return(View("NuevoPedido", pedidoView)); } else { // PedidoView pedidoView = new PedidoView(); //EntretenimientoPedido entrepedido; var pedidoView = Session["PedidoView"] as PedidoView; var entre = db.Entretenimientoes.Find(id); entrepedido = new EntretenimientoPedido() { IdEntrete = entre.IdEntrete, Nombre = entre.Nombre, Precio = entre.Precio }; pedidoView.Entretenimientos.Add(entrepedido); var listaClientes = db.Clientes.ToList(); ViewBag.ClienteId = new SelectList(listaClientes, "ClienteId", "NombreCliente"); var listaEntre = db.Entretenimientoes.ToList(); ViewBag.IdEntrete = new SelectList(listaEntre, "IdEntrete", "Nombre"); return(View("NuevoPedido", pedidoView)); } }
public void Inserir(PedidoView input) { var obj = _mapper.Map <Pedido>(input); _PedidoRepository.Inserir(obj); }
public void Alterar(PedidoView input) { var obj = _mapper.Map <Pedido>(input); _PedidoRepository.Alterar(obj); }