예제 #1
0
        private bool InsertModsToDb(DMMods mods, Guid userGuid)
        {
            var entity = MapModsToCoreMods(mods, userGuid);

            _contractModificationService.Add(entity);
            return(true);
        }
예제 #2
0
        private ContractModification MapModsToCoreMods(DMMods mods, Guid userGuid)
        {
            modsEntity = new ContractModification();

            if (string.IsNullOrWhiteSpace(mods.POPStart))
            {
                mods.POPStart = DateTime.UtcNow.ToShortDateString();
            }
            if (string.IsNullOrWhiteSpace(mods.POPEnd))
            {
                mods.POPEnd = DateTime.UtcNow.ToShortDateString();
            }
            if (string.IsNullOrWhiteSpace(mods.AwardAmount))
            {
                mods.AwardAmount = "0";
            }
            if (string.IsNullOrWhiteSpace(mods.FundingAmount))
            {
                mods.FundingAmount = "0";
            }

            modsEntity.ContractModificationGuid = mods.ContractModificationGuid;
            modsEntity.ContractGuid             = mods.ContractGuid;
            modsEntity.ProjectNumber            = mods.ProjectNumber;
            modsEntity.ModificationNumber       = mods.ModNumber;
            modsEntity.ModificationTitle        = mods.ModTitle;
            if (!string.IsNullOrWhiteSpace(mods.POPStart))
            {
                modsEntity.POPStart = DateTime.Parse(mods.POPStart);
            }
            if (!string.IsNullOrWhiteSpace(mods.POPEnd))
            {
                modsEntity.POPEnd = DateTime.Parse(mods.POPEnd);
            }
            if (!string.IsNullOrWhiteSpace(mods.AwardAmount))
            {
                modsEntity.AwardAmount = Decimal.Parse(mods.AwardAmount);
            }
            if (!string.IsNullOrWhiteSpace(mods.FundingAmount))
            {
                modsEntity.FundingAmount = Decimal.Parse(mods.FundingAmount);
            }
            modsEntity.CreatedOn = DateTime.UtcNow;
            modsEntity.IsActive  = true;
            modsEntity.IsDeleted = false;
            modsEntity.CreatedBy = userGuid;
            modsEntity.UpdatedBy = userGuid;
            modsEntity.UpdatedOn = DateTime.UtcNow;
            return(modsEntity);
        }
예제 #3
0
        private DMMods CheckDuplicateMods(DMMods mods)
        {
            mods.IsValid = true;
            var isModNumberExist = _contractModificationService.IsExistModificationNumber(mods.ContractGuid, mods.ContractModificationGuid, mods.ModNumber);

            if (isModNumberExist)
            {
                mods.Reason       = "Duplicate Mod Number";
                mods.IsValid      = false;
                mods.ImportStatus = ImportStatus.Fail.ToString();
            }

            var isModTitleExist = _contractModificationService.IsExistModificationTitle(mods.ContractGuid, mods.ContractModificationGuid, mods.ModTitle);

            if (isModTitleExist)
            {
                mods.Reason       = "Duplicate Mod Title";
                mods.IsValid      = false;
                mods.ImportStatus = ImportStatus.Fail.ToString();
            }
            return(mods);
        }
예제 #4
0
        private DMMods EnableDisableDeleteMods(DMMods mods, Guid modsGuid)
        {
            var action = mods.Action.ToLower();

            if (action == ImportAction.Delete.ToString().ToLower())
            {
                var result = DeleteMods(modsGuid);
                mods.Reason = "Deleted Successfully";
            }
            else if (action == ImportAction.Enable.ToString().ToLower())
            {
                var result = EnableDisableMods(true, modsGuid);
                mods.Reason = "Enable Successfully";
            }
            else
            {
                var result = EnableDisableMods(false, modsGuid);
                mods.Reason = "Disable Successfully";
            }

            mods.ImportStatus = Core.Entities.ImportStatus.Success.ToString();
            return(mods);
        }
예제 #5
0
        private DMMods ModsValidation(DMMods mods)
        {
            mods.IsValid = true;

            if (string.IsNullOrWhiteSpace(mods.POPStart) || mods.POPStart == "NULL")
            {
                mods.POPStart = DateTime.UtcNow.ToShortDateString();
            }
            if (string.IsNullOrWhiteSpace(mods.POPEnd) || mods.POPEnd == "NULL")
            {
                mods.POPEnd = DateTime.UtcNow.ToShortDateString();
            }
            if (string.IsNullOrWhiteSpace(mods.AwardAmount) || mods.AwardAmount == "NULL")
            {
                mods.AwardAmount = "0";
            }
            if (string.IsNullOrWhiteSpace(mods.FundingAmount) || mods.FundingAmount == "NULL")
            {
                mods.FundingAmount = "0";
            }

            if (!string.IsNullOrWhiteSpace(mods.POPStart.ToString()))
            {
                var isPOPStartValid = ValidationHelper.IsValidDate(mods.POPStart.ToString());
                if (!isPOPStartValid)
                {
                    mods.ImportStatus = ImportStatus.Fail.ToString();
                    mods.IsValid      = false;
                    mods.Reason      += "Invalid POPStart date";
                }
            }

            if (!string.IsNullOrWhiteSpace(mods.POPEnd.ToString()))
            {
                var isPOPEndValid = ValidationHelper.IsValidDate(mods.POPEnd.ToString());
                if (!isPOPEndValid)
                {
                    mods.ImportStatus = ImportStatus.Fail.ToString();
                    mods.IsValid      = false;
                    mods.Reason      += "Invalid POPEnd date";
                }
            }

            if (!string.IsNullOrWhiteSpace(mods.AwardAmount.ToString()))
            {
                var isValidAwardAmount = ValidationHelper.IsValidDecimal(mods.AwardAmount.ToString());
                if (!isValidAwardAmount)
                {
                    mods.ImportStatus = ImportStatus.Fail.ToString();
                    mods.IsValid      = false;
                    mods.Reason      += "Invalid Award Amount";
                }
            }

            if (!string.IsNullOrWhiteSpace(mods.FundingAmount.ToString()))
            {
                var isValidFundingAmount = ValidationHelper.IsValidDecimal(mods.FundingAmount.ToString());
                if (!isValidFundingAmount)
                {
                    mods.ImportStatus = ImportStatus.Fail.ToString();
                    mods.IsValid      = false;
                    mods.Reason      += "Invalid Funding Amount";
                }
            }
            return(mods);
        }