コード例 #1
0
        public async Task <IdOutputDto <int> > UpdateDivisionUnit(UpdateJobUnitInput input)
        {
            var jobUnit = await _jobUnitRepository.GetAsync(input.JobId);

            #region Setting the values to be updated

            jobUnit.JobNumber          = input.JobNumber;
            jobUnit.Caption            = input.Caption;
            jobUnit.TypeOfCurrencyId   = input.TypeOfCurrencyId;
            jobUnit.IsActive           = input.IsActive;
            jobUnit.OrganizationUnitId = input.OrganizationUnitId;
            jobUnit.IsDivision         = true;

            #endregion

            await _jobUnitManager.UpdateAsync(jobUnit);

            await CurrentUnitOfWork.SaveChangesAsync();

            IdOutputDto <int> response = new IdOutputDto <int>()
            {
                JobId = jobUnit.Id
            };

            return(response);
        }
コード例 #2
0
        public async Task <IdOutputDto <int> > UpdateJobUnit(UpdateJobUnitInput input)
        {
            if (input.ChartOfAccountId == 0)
            {
                throw new UserFriendlyException(L("BudgetFormat is Required"));
            }
            var jobUnit = await _jobUnitRepository.GetAsync(input.JobId);

            #region Setting the values to be updated
            jobUnit.JobNumber           = input.JobNumber;
            jobUnit.Caption             = input.Caption;
            jobUnit.IsCorporateDefault  = input.IsCorporateDefault;
            jobUnit.RollupAccountId     = input.RollupAccountId;
            jobUnit.TypeOfCurrencyId    = input.TypeOfCurrencyId;
            jobUnit.RollupJobId         = input.RollupJobId;
            jobUnit.TypeOfJobStatusId   = input.TypeOfJobStatusId;
            jobUnit.TypeOfBidSoftwareId = input.TypeOfBidSoftwareId;
            jobUnit.IsApproved          = input.IsApproved;
            jobUnit.IsActive            = input.IsActive;
            jobUnit.IsICTDivision       = input.IsICTDivision;
            jobUnit.TypeofProjectId     = input.TypeofProjectId;
            jobUnit.TaxRecoveryId       = input.TaxRecoveryId;
            jobUnit.ChartOfAccountId    = input.ChartOfAccountId;
            jobUnit.RollupCenterId      = input.RollupCenterId;
            #endregion


            await _jobUnitManager.UpdateAsync(jobUnit);


            //disable the SoftDelete Filter
            #region Adding the new lines to jobAccount
            using (UnitOfWorkManager.Current.DisableFilter(AbpDataFilters.SoftDelete))
            {
                //get all jobaccounts and Lines
                var jobaccountsList = (from lines in _accountUnitRepository.GetAll().Where(p => p.ChartOfAccountId == input.ChartOfAccountId)
                                       join jobacc in _jobAccountUnitRepository.GetAll() on lines.Id equals jobacc.AccountId into jobaccount
                                       from jobaccounts in jobaccount.DefaultIfEmpty()
                                       join rollUpAccount in _accountUnitRepository.GetAll() on lines.RollupAccountId equals rollUpAccount.Id into rollUpAccount
                                       from rollUpAccounts in rollUpAccount.DefaultIfEmpty()
                                       join rollUpDivision in _jobUnitRepository.GetAll().Where(u => u.IsDivision == true) on lines.RollupJobId equals rollUpDivision.Id into rollUpDivision
                                       from rollUpDivisions in rollUpDivision.DefaultIfEmpty()
                                       select new
                {
                    lines,
                    jobaccounts,
                    rollUpAccountDescription = rollUpAccounts.Caption,
                    rollUpDivisionDescription = rollUpDivisions.Caption
                }).ToList();
                //bulkinsertion
                foreach (var jobaccount in jobaccountsList)
                {
                    if (ReferenceEquals(jobaccount.jobaccounts, null) && !jobaccount.lines.IsDeleted)
                    {
                        CreateJobAccountUnitInput jobAccount = new CreateJobAccountUnitInput
                        {
                            JobId                    = input.JobId,
                            AccountId                = jobaccount.lines.Id,
                            RollupAccountId          = input.RollupAccountId,
                            RollupJobId              = input.RollupJobId,
                            Description              = jobaccount.lines.Caption,
                            RollupJobDescription     = jobaccount.rollUpDivisionDescription,
                            RollupAccountDescription = jobaccount.rollUpAccountDescription,
                        };

                        await _jobAccountUnitAppService.CreateJobAccountUnit(jobAccount);
                    }
                }
            }
            #endregion



            #region updating all JobAccounts of Job
            //bulk update
            if (!ReferenceEquals(input.JobAccountList, null))
            {
                foreach (var jobAccounts in input.JobAccountList)
                {
                    await _jobAccountUnitAppService.UpdateJobAccountUnit(jobAccounts);
                }
            }
            IdOutputDto <int> responseDto = new IdOutputDto <int>
            {
                JobId = jobUnit.Id
            };
            return(responseDto);

            #endregion
        }