public async Task <DeliveryDto> Get(IExecutionContext executionContext, string id) { AssertExecutionContext(executionContext); var entity = await _deliveryRepo.Get(id); return(_deliveryMapper.From(entity)); }
public DeliveryDto Get(Guid? id) { if (!id.HasValue) { throw new NullReferenceException("This Id is not Valid"); } var delvery = _delviryRepository.Get(id.Value); if (delvery == null) { throw new NullReferenceException("This Customer Can not be found"); } return mapper.Map<DeliveryDto>(delvery); }
// GET: Deliveries/Edit/5 public IActionResult Edit(int?id) { if (id == null) { return(NotFound()); } var delivery = _deliveryrepository.Get(id); if (delivery == null) { return(NotFound()); } ViewData["CheckId"] = new SelectList(_furnituresalerepository.GetFurnitureSalesInfo(), "CheckId", "CheckId", delivery.CheckId); return(View(delivery)); }
public ICommandResult Handle(CreatePedidoCommand command) { // Fail Fast Validation command.validate(); if (command.Invalid) { return(new GenericCommandResult(false, "Pedido inválido", null)); } // 1. Recupera o cliente var aluno = _alunoRepository.Get(command.Aluno); // 2. Calcula a taxa de entrega var delivery = _deliveryRepository.Get(command.ZipCode); // 3. Obtém o cupom de desconto var desconto = _descontoRepository.Get(command.PromoCode); // 4. Gera o pedido var cursos = _cursoRepository.Get(ExtractGuids.Extract(command.Items)).ToList(); var pedido = new Pedido(aluno, delivery, desconto); foreach (var item in command.Items) { var curso = cursos.Where(x => x.Id == item.Curso).FirstOrDefault(); pedido.AddItem(curso, item.Quantidade); } // 5. Agrupa as notificações AddNotifications(pedido.Notifications); // 6. Verifica se deu tudo certo if (Invalid) { return(new GenericCommandResult(false, "Falha ao gerar o pedido", Notifications)); } // 7. Retorna o resultado _pedidoRepository.Save(pedido); return(new GenericCommandResult(true, $"Pedido {pedido.Numero} gerado com sucesso", pedido)); }
public Delivery Get(string id) { return(Repo.Get(new Guid(id))); }