public async Task <IActionResult> CadastrarNovaEncomenda(NovaEncomendaViewModel model) { try { if (!ModelState.IsValid) { return(PartialView("_CadastroEncomenda", model)); } await _encomendaService.Salvar(new Encomenda { PontoVendaId = _loggedUser.EmpresaId, PontoRetiradaId = model.PontoRetiradaId, DataPedido = model.DataPedido.Value, NotaFiscal = model.NotaFiscal, NumeroPedido = model.NumeroPedido }); return(Ok(Url.RouteUrl("Encomenda_PontoVenda_Index"))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(PartialView("_CadastroEncomenda", model)); } }
public async Task <IActionResult> NovaEncomenda() { var pontosRetirada = await _empresaService.ObterPontosRetirada(); NovaEncomendaViewModel model = new NovaEncomendaViewModel { ListaPontoRetirada = pontosRetirada.Select(p => new SelectListItem(p.NomeFantasia, p.Id.ToString())) }; return(PartialView("_CadastroEncomenda", model)); }