Пример #1
0
        public async Task <IdOutputDto <int> > CreateDivisionUnit(CreateJobUnitInput input)
        {
            var chartofaccount = _coaUnitRepository.FirstOrDefault(p => p.IsCorporate);

            if (ReferenceEquals(chartofaccount, null))
            {
                throw new UserFriendlyException(L("Pleasesetupchartofaccount"));
            }
            var jobUnit = new JobUnit(jobnumber: input.JobNumber, caption: input.Caption, iscorporatedefault: input.IsCorporateDefault, rollupaccountid: input.RollupAccountId,
                                      typeofcurrencyid: input.TypeOfCurrencyId, rollupjobid: input.RollupJobId, typeofjobstatusid: input.TypeOfJobStatusId, typeofbidsoftwareid: input.TypeOfBidSoftwareId,
                                      isapproved: input.IsApproved, isactive: input.IsActive, isictdivision: input.IsICTDivision, organizationunitid: input.OrganizationUnitId, typeofprojectid: input.TypeofProjectId,
                                      taxrecoveryid: input.TaxRecoveryId, chartofaccountid: chartofaccount.Id, rollupcenterid: input.RollupCenterId, isdivision: true, taxcreditid: input.TaxCreditId);
            IdOutputDto <int> response = new IdOutputDto <int>
            {
                JobId = await _jobUnitManager.CreateAsync(jobUnit)
            };

            return(response);
        }
Пример #2
0
        /// <summary>
        /// Validating the Job
        /// </summary>
        /// <param name="jobUnit"></param>
        /// <returns></returns>
        protected virtual async Task ValidateJobUnitAsync(JobUnit jobUnit)
        {
            //Validating if Duplicate JobNumber exists
            if (JobUnitRepository != null)
            {
                var jobUnits = (await JobUnitRepository.GetAllListAsync(p => p.JobNumber == jobUnit.JobNumber));

                if (jobUnit.Id == 0)
                {
                    if (jobUnits.Count > 0)
                    {
                        throw new UserFriendlyException(L("DuplicateNumber"), jobUnit.JobNumber);
                    }
                }
                else
                {
                    if (jobUnits.FirstOrDefault(p => p.Id != jobUnit.Id && p.JobNumber == jobUnit.JobNumber) != null)
                    {
                        throw new UserFriendlyException(L("DuplicateNumber"), jobUnit.JobNumber);
                    }
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Updating Job Details
        /// </summary>
        /// <param name="job"></param>
        /// <returns></returns>
        public virtual async Task UpdateAsync(JobUnit job)
        {
            await ValidateJobUnitAsync(job);

            await JobUnitRepository.UpdateAsync(job);
        }
Пример #4
0
        public virtual async Task <int> CreateAsync(JobUnit jobUnit)
        {
            await ValidateJobUnitAsync(jobUnit);

            return(await JobUnitRepository.InsertAndGetIdAsync(jobUnit));
        }