private async Task <IWrappedResponse> AcceptTransportAction(Rules.TransportOfferings.AcceptTransport.MainRule mainRule)
        {
            var transport = mainRule.Context.Transport;

            transport.Status            = TransportStatus.Planned;
            transport.WinningBid.Status = TransportBidStatus.Accepted;
            transport.OrderMatch.Status = OrderMatchStatus.TransportScheduled;
            transport.OrderMatch.Supply.Detail.Status = OrderLoadStatus.TransportPlanned;
            transport.OrderMatch.Demand.Detail.Status = OrderLoadStatus.TransportPlanned;

            // let all others no that they have lost
            var allOtherActiveBids = _olmaTransportBidRepo.FindAll()
                                     .IgnoreQueryFilters()
                                     .Where(i => i.TransportId == mainRule.Context.TransportId &&
                                            i.Id != transport.WinningBid.Id &&
                                            i.Status == TransportBidStatus.Active)
                                     .ToList();

            foreach (var bid in allOtherActiveBids)
            {
                bid.Status = TransportBidStatus.Lost;
            }

            _olmaTransportRepo.Save();

            var transportOffering = Mapper.Map <TransportOffering>(transport);

            return(Ok(transportOffering));
        }
Esempio n. 2
0
 public ContextModel(int parent, MainRule rule) : base(parent, rule)
 {
 }