Example #1
0
        private void HandleMessage(TenderMessageDTO message, string routingKey)
        {
            using (var scope = _service.CreateScope())
            {
                ITenderService tenderService = scope.ServiceProvider.GetRequiredService <ITenderService>();
                Tender         tender        = tenderService.GetTenderByRoutingKey(routingKey);
                if (tender.IsClosed || tender.EndDate.CompareTo(DateTime.Now) <= 0)
                {
                    throw new Exception("Tender is closed!");
                }

                TenderMessage tenderMessage = new TenderMessage();
                tenderMessage.Identification  = message.Identification;
                tenderMessage.ReplyRoutingKey = message.ReplyRoutingKey;
                tenderMessage.TenderId        = tender.Id;
                tenderMessage.Offers          = new List <TenderOffer>();

                foreach (var o in message.Offers)
                {
                    TenderOffer to = new TenderOffer()
                    {
                        Code = o.Code, Name = o.Name, Quantity = o.Quantity, Price = o.Price
                    };
                    tenderMessage.Offers.Add(to);
                }
                scope.ServiceProvider.GetRequiredService <ITenderMessageService>().CreateTenderMessage(tenderMessage);
            }
        }
Example #2
0
        public async Task <IActionResult> OffersAsync(int tenderId)
        {
            Tender tender = await _tenderService.GetTender(tenderId);

            if (tender == null)
            {
                return(RedirectToAction("Index"));
            }

            if (tender.IsClosed)
            {
                TenderMessage tenderMessage = await _tenderService.GetAcceptedMessage(tenderId);

                if (tenderMessage == null)
                {
                    return(RedirectToAction("Index"));
                }
                return(RedirectToAction("Offer", new { messageId = tenderMessage.Id }));
            }

            return(View(await _tenderService.GetAllMessages(tenderId)));
        }
 public void UpdateTenderMessage(TenderMessage tm)
 {
     _context.TenderMessages.Update(tm);
     _context.SaveChanges();
 }
 public void CreateTenderMessage(TenderMessage tm)
 {
     _context.TenderMessages.Add(tm);
     _context.SaveChanges();
 }
 public void UpdateTenderMessage(TenderMessage tm)
 {
     _tenderMessageRepository.UpdateTenderMessage(tm);
 }
 public void CreateTenderMessage(TenderMessage tm)
 {
     _tenderMessageRepository.CreateTenderMessage(tm);
 }