Ejemplo n.º 1
0
        public async Task SendTenderByUnitSecretaryForModificationAsync(ReturnTenderToDataEntryFromUnitFormodificationsModel returnTenderToDataEntryFromUnitFormodificationsModel)
        {
            var    tenderId = Util.Decrypt(returnTenderToDataEntryFromUnitFormodificationsModel.tenderIdString);
            Tender tender   = await _tenderQueries.FindTenderWithUnitHistoryById(tenderId);

            _tenderDomainService.IsValidToReturnTenderToDataEntryForEdit(tender);
            tender.DeactiveAllAssingments();
            tender.SetUnitStatus(Enums.TenderUnitStatus.ReturnedToAgencyForEdit);
            tender.DeleteUnitModificationAttachments();
            TenderUnitStatusesHistory tenderUnitStatusesHistory = new TenderUnitStatusesHistory(comment: returnTenderToDataEntryFromUnitFormodificationsModel.notes, tenderUnitStatusId: (int)Enums.TenderUnitStatus.ReturnedToAgencyForEdit, updateTypeId: returnTenderToDataEntryFromUnitFormodificationsModel.modificationTypeId, estimatedValue: tender.EstimatedValue);

            tender.TenderUnitStatusesHistories.Add(tenderUnitStatusesHistory);
            tender.UpdateTenderStatus(Enums.TenderStatus.ReturnedFromUnitToAgencyForEdit,
                                      returnTenderToDataEntryFromUnitFormodificationsModel.notes,
                                      _httpContextAccessor.HttpContext.User.UserId(),
                                      TenderActions.SendTenderByUnitSecretaryForModification);
            List <TenderAttachment> tenderAttachments = new List <TenderAttachment>();

            foreach (var file in returnTenderToDataEntryFromUnitFormodificationsModel.files)
            {
                tenderAttachments.Add(new TenderAttachment(file.Name, file.FileNetReferenceId, (int)Enums.AttachmentType.UnitModificationsAttachmentsToDataEntry));
            }
            tender.Attachments.AddRange(tenderAttachments);
            #region [Send Notification]
            NotificationArguments NotificationArguments = new NotificationArguments
            {
                BodyEmailArgs    = new object[] { tender.ReferenceNumber },
                SubjectEmailArgs = new object[] { },
                PanelArgs        = new object[] { tender.ReferenceNumber },
                SMSArgs          = new object[] { tender.ReferenceNumber }
            };
            MainNotificationTemplateModel mainNotificationTemplateModel = new MainNotificationTemplateModel(NotificationArguments,
                                                                                                            $"Tender/Details?STenderId={Util.Encrypt(tender.TenderId)}",
                                                                                                            NotificationEntityType.Tender,
                                                                                                            tender.TenderId.ToString(),
                                                                                                            tender.BranchId);

            await _notificationAppService.SendNotificationForBranchUsers(NotificationOperations.Auditor.OperationsOnTheTender.editTenderFromUnit, tender.BranchId, mainNotificationTemplateModel);

            await _notificationAppService.SendNotificationForBranchUsers(NotificationOperations.DataEntry.OperationsOnTheTender.editTenderFromUnit, tender.BranchId, mainNotificationTemplateModel);

            #endregion
            _genericCommandRepository.Update(tender);
            await _genericCommandRepository.SaveAsync();
        }