public async Task <IActionResult> InsertOrder([FromBody] OrdenEntregaViewModel ordenEntrega) { try { List <ItemEntrega> items = new List <ItemEntrega>(); foreach (var item in ordenEntrega.Items) { items.Add(new ItemEntrega(item.Codigo, item.Descripcion)); } OrdenEntrega obj = new OrdenEntrega(ordenEntrega.NombreCliente, ordenEntrega.Telefono, ordenEntrega.LatitudDestino, ordenEntrega.LongitudDestino, items ); await _ordenEntregaRepository.Insert(obj); await _unitOfWork.Commit(); return(Ok()); } catch (Exception ex) { } return(BadRequest()); }
public async Task <VoidResult> Handle(InsertOrdenEntregaCommand request, CancellationToken cancellationToken) { Dictionary <string, string> items = new Dictionary <string, string>(); foreach (var item in request.OrdenEntrega.Items) { items.Add(item.Codigo, item.Descripcion); } Domain.Model.Disitribucion.OrdenEntrega obj = new Domain.Model.Disitribucion.OrdenEntrega(request.OrdenEntrega.NombreCliente, request.OrdenEntrega.Telefono, request.OrdenEntrega.LatitudDestino, request.OrdenEntrega.LongitudDestino, items ); await _ordenEntregaRepository.Insert(obj); await _unitOfWork.Commit(); return(new VoidResult()); }