Ejemplo n.º 1
0
        public async Task <Enquiry> SendEnquiry(EnquiryModel enquiryModel)
        {
            Enquiry enquiry = _mapper.Map <Enquiry>(enquiryModel);
            Tender  tender  = await _tenderAppService.FindTenderByTenderId(enquiry.TenderId);

            if (tender != null)
            {
                await _enquiryDomain.CheckCanAddEnquiry(tender, enquiry.CommericalRegisterNo);
            }

            #region
            NotificationArguments NotificationArgument = new NotificationArguments();
            NotificationArgument.BodyEmailArgs    = new object[] { "", tender?.TenderName, tender?.ReferenceNumber, enquiryModel.EnquiryName };
            NotificationArgument.SubjectEmailArgs = new object[] { };
            NotificationArgument.PanelArgs        = new object[] { tender?.ReferenceNumber };
            NotificationArgument.SMSArgs          = new object[] { tender?.ReferenceNumber };
            #endregion

            MainNotificationTemplateModel mainNotificationTemplateModel;
            if (tender != null)
            {
                mainNotificationTemplateModel = new MainNotificationTemplateModel(NotificationArgument,
                                                                                  $"Enquiry/SupplierEnquiriesOnTender?id={Util.Encrypt(tender.TenderId)}",
                                                                                  NotificationEntityType.Tender,
                                                                                  tender.TenderId.ToString(),
                                                                                  tender.TechnicalOrganizationId);

                await _notificationAppService.SendNotificationForCommitteeUsers(NotificationOperations.TechnicalCommitteeSecretary.InquiriesAboutTender.vendoraskquestion, tender?.TechnicalOrganizationId, mainNotificationTemplateModel);

                tender.AddActionHistory(tender.TenderStatusId, TenderActions.AskQuestion, "", _httpContextAccessor.HttpContext.User.UserId());

                var request = new AgencyCommunicationRequest(tender.TenderId, (int)Enums.AgencyCommunicationRequestType.Enquiry, (int)Enums.AgencyCommunicationRequestStatus.PendingEnquiryForReply, RoleNames.supplier);
                tender.AddAgencyCommunicationRequest(request);
                enquiry.SetCommunicationRequest(request);
            }
            return(await _enquiryCommands.CreateAsync(enquiry));
        }