public async Task IsValidToCreate_WithNullDates_ThrowsBusinessException()
        {
            #region Arrange

            PostQualificationApplyDocumentsModel model = new PostQualificationApplyDocumentsModel()
            {
                TenderStatusId     = 0,
                TenderCountriesIDs = new List <int>()
                {
                    1
                },
                TechnicalOrganizationId       = null,
                IsAgancyHasTechnicalCommittee = true,
                PreQualificationCommitteeId   = 0
            };
            _moqHttpContextAccessor.Setup(con => con.HttpContext.User.Claims).Returns(() => new List <Claim>()
            {
                new Claim(IdentityConfigs.Claims.Role, RoleNames.PreQualificationCommitteeSecretary)
            });

            #endregion

            var e = Assert.ThrowsAsync <BusinessRuleException>(async() => await _Sut.IsValidToCreate(model));

            Assert.Equal(Resources.TenderResources.ErrorMessages.EnterAllQualificationDates, e.Result.Message);
        }
        IsValidToCreatePostQualification_WithCheckingDateLessThanLastPresentationDate_ThrowsBusinessException()
        {
            #region Arrange

            PostQualificationApplyDocumentsModel model = new PostQualificationApplyDocumentsModel()
            {
                TenderStatusId = 0,
                TenderAreaIDs  = new List <int>()
                {
                    1
                },
                TechnicalOrganizationId       = null,
                IsAgancyHasTechnicalCommittee = true,
                PreQualificationCommitteeId   = 0,
                LastEnqueriesDate             = DateTime.Now.AddDays(1),
                LastOfferPresentationDate     = DateTime.Now.AddDays(3),
                LastOfferPresentationTime     = "5:00",
                OffersCheckingDate            = DateTime.Now.AddDays(2)
            };
            _moqHttpContextAccessor.Setup(con => con.HttpContext.User.Claims).Returns(() => new List <Claim>()
            {
                new Claim(IdentityConfigs.Claims.Role, RoleNames.PreQualificationCommitteeSecretary)
            });

            #endregion

            var e = Assert.ThrowsAsync <BusinessRuleException>(async() =>
                                                               await _Sut.IsValidToCreatePostQualification(model));

            Assert.Equal(Resources.QualificationResources.ErrorMessages.InvalidOffersCheckingDate, e.Result.Message);
        }
Esempio n. 3
0
        public async Task ShouldCreatePostQulaification()
        {
            #region Arrange
            var userId                 = 1;
            var agencyCode             = "32323";
            var postQualificationModel = new PostQualificationApplyDocumentsModel()
            {
                CommercialNumbers = new List <string>()
                {
                    "4343", "1010"
                },
                PostQualificationTenderId = 2,
                postQualificationIdString = null,
                TenderName                = "GGg",
                TenderId                  = 323,
                LastEnqueriesDate         = DateTime.Now,
                LastOfferPresentationDate = DateTime.Now,
                OffersCheckingDate        = DateTime.Now,
                branchId                  = 2,
                TenderActivitieIDs        = new List <int>()
                {
                    1, 2
                },
                TenderAreaIDs = new List <int>()
                {
                    1, 2
                },

                Attachments = new List <TenderAttachmentModel>(),
            };
            _moqQualificationQueries.Setup(m => m.GetPostQualificationById(It.IsAny <int>()))
            .Returns(() =>
            {
                return(Task.FromResult <Tender>(new TenderDefault().GetGeneralTender()));
            });
            #endregion Arrange

            await _sut.CreatePoatQualification(postQualificationModel, userId, agencyCode);

            _moqGenericCommandRepository.Verify(m => m.SaveAsync(), Times.Once);
        }
Esempio n. 4
0
        public async Task IsValidToCreatePostQualification(PostQualificationApplyDocumentsModel tender)
        {
            if (tender == null)
            {
                throw new BusinessRuleException(Resources.QualificationResources.ErrorMessages.QualificationNotExit);
            }
            if (tender.TenderStatusId == 0)
            {
                tender.TenderStatusId = (int)Enums.TenderStatus.Established;
            }

            if (tender.InsideKSA)
            {
                if (tender.TenderAreaIDs == null || tender.TenderAreaIDs.Count() == 0)
                {
                    throw new BusinessRuleException(Resources.TenderResources.ErrorMessages.EnterTenderAreas);
                }
            }
            else
            {
                if (tender.TenderCountriesIDs == null || tender.TenderCountriesIDs.Count() == 0)
                {
                    throw new BusinessRuleException(Resources.TenderResources.ErrorMessages.EnterTenderCountries);
                }
            }

            if (tender.TechnicalOrganizationId == null && tender.IsAgancyHasTechnicalCommittee && _httpContextAccessor.HttpContext.User.UserRole() != RoleNames.PreQualificationCommitteeSecretary)
            {
                throw new BusinessRuleException(Resources.TenderResources.ErrorMessages.EnterTechnicalCommittee);
            }
            if (tender.PreQualificationCommitteeId == 0)
            {
                tender.PreQualificationCommitteeId = null;
            }
            if (tender.LastOfferPresentationDate == null || tender.LastEnqueriesDate == null || string.IsNullOrEmpty(tender.LastOfferPresentationTime))
            {
                throw new BusinessRuleException(Resources.TenderResources.ErrorMessages.EnterAllQualificationDates);
            }
            string message = "";
            int    flag    = 1;

            if (tender.LastEnqueriesDate < DateTime.Now)
            {
                flag   *= 0;
                message = Resources.SharedResources.ErrorMessages.DateLessThanToday + "\n";
                throw new BusinessRuleException(message);
            }
            if (tender.OffersCheckingDate.HasValue && tender.OffersCheckingDate <= tender.LastEnqueriesDate)
            {
                flag   *= 0;
                message = Resources.TenderResources.ErrorMessages.CheckingDateLessThanEnquiriesDate + "\n";
                throw new BusinessRuleException(message);
            }

            if (tender.OffersCheckingDate.HasValue && tender.LastOfferPresentationDate >= tender.OffersCheckingDate)
            {
                throw new BusinessRuleException(Resources.QualificationResources.ErrorMessages.InvalidOffersCheckingDate);
            }

            Util.DetermineTimesForDates(tender.LastOfferPresentationDate.Value, (int)Enums.TimeMessagesType.Qualification, _rootConfiguration);
        }