コード例 #1
0
 public Task <ContractResult> CreateContract(
     IOrganizationAccountManager am,
     ContractInput model)
 {
     _logger.LogInformation(GetLogMessage("Creating contract as AM"));
     model.ContractorOrganizationId = am.OrganizationId;
     return(CreateContract(model));
 }
コード例 #2
0
 public void CreateOrEditContract(ContractInput contractInput)
 {
     if (contractInput.Id == 0)
     {
         Create(contractInput);
     }
     else
     {
         Update(contractInput);
     }
 }
コード例 #3
0
        private void Update(ContractInput contractInput)
        {
            var contractEntity = contractRepository.GetAll().Where(x => !x.IsDelete).SingleOrDefault(x => x.Id == contractInput.Id);

            if (contractEntity == null)
            {
            }
            ObjectMapper.Map(contractInput, contractEntity);
            SetAuditEdit(contractEntity);
            contractRepository.Update(contractEntity);
            CurrentUnitOfWork.SaveChanges();
        }
コード例 #4
0
        private void Create(ContractInput contractInput)
        {
            var contractEntity = ObjectMapper.Map <Contract>(contractInput);

            SetAuditInsert(contractEntity);
            var id = contractRepository.InsertAndGetId(contractEntity);

            foreach (var product in contractInput.Products)
            {
                // insert vo bang ProductContract co productId va contractId
                ContractDetailInput detailInput = new ContractDetailInput(id, product.Id, product.MerCode, product.MerName, product.Quantity, product.Price, product.Note);
                var detailEntity = ObjectMapper.Map <ContractDetail>(detailInput);
                SetAuditInsert(detailEntity);
                detailRepository.Insert(detailEntity);
            }

            CurrentUnitOfWork.SaveChanges();
        }
コード例 #5
0
        public async Task <IActionResult> CreateContract([FromRoute] Guid organizationId, [FromBody] ContractInput model)
        {
            var contract = await _contractService
                           .CreateContract
                               (_pao.Value, model);

            return(Ok(contract));
        }
コード例 #6
0
 /// <summary>
 /// 新增联系人
 /// </summary>
 /// <param name="input"></param>
 public async Task AddContractAsync(ContractInput input)
 {
     var contract = input.MapTo <Contract>();
     await _contractRepository.InsertAsync(contract);
 }
コード例 #7
0
        public async Task <Contract> AddContract([Service] DBAttendanceContext dBAttendanceContext, ContractInput input)
        {
            try
            {
                var contract = new Contract
                {
                    StartDate      = input.StartDate,
                    FinishDate     = input.FinishDate,
                    Mount          = input.Mount,
                    ExtraHours     = input.ExtraHours,
                    EmployeeCardId = input.EmployeeCardId
                };
                dBAttendanceContext.Contract.Add(contract);
                await dBAttendanceContext.SaveChangesAsync();

                return(contract);
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }
コード例 #8
0
        public async Task <Contract> ModifyContract([Service] DBAttendanceContext dBAttendanceContext, ContractInput input)
        {
            try
            {
                var contract = await dBAttendanceContext.Contract.FindAsync(input.Id);

                if (contract != null)
                {
                    contract.StartDate  = input.StartDate;
                    contract.FinishDate = input.FinishDate;
                    contract.Mount      = input.Mount;
                    contract.State      = input.State;
                    contract.ExtraHours = input.ExtraHours;
                    await dBAttendanceContext.SaveChangesAsync();

                    return(contract);
                }
                else
                {
                    throw new QueryException("Contrato no encontrado.");
                }
            }
            catch (System.Exception e)
            {
                throw new QueryException(e.Message);
            }
        }
コード例 #9
0
 public void CreateOrEditContract([FromBody] ContractInput input)
 {
     contractAppService.CreateOrEditContract(input);
 }
コード例 #10
0
ファイル: WrapperPage.cs プロジェクト: sdamian/SeleniumDemo
 public void SetContract(string contractNumber)
 {
     ContractInput.Clear();
     ContractInput.SendKeys(contractNumber);
 }
コード例 #11
0
        public async Task <IActionResult> CreateContract([FromRoute] Guid organizationId, [FromBody] ContractInput model)
        {
            var contract = await _contractService.CreateContract(_accountManager, model);

            if (contract.Succeeded)
            {
                return(await GetContract(organizationId, contract.ContractId.Value));
            }

            return(BadRequest());
        }
コード例 #12
0
        private async Task <ContractResult> CreateContract(ContractInput input)
        {
            _logger.LogInformation(
                GetLogMessage(
                    $@"Creating Contract For Contractor: {input.ContractorId} in Project: {input.ProjectId}"));

            var retVal = new ContractResult
            {
            };

            var project = await _projectRepository.Queryable()
                          .Include(x => x.CustomerAccount)
                          .ThenInclude(x => x.OrganizationCustomer)
                          .Include(x => x.Customer)
                          .ThenInclude(x => x.OrganizationMarketer)
                          .Include(x => x.OrganizationProjectManager)
                          .Where(x => x.Id == input.ProjectId && x.ProjectManagerOrganizationId == input.ContractorOrganizationId)
                          .FirstAsync();

            if (project.Status == ProjectStatus.Paused || project.Status == ProjectStatus.Ended)
            {
                retVal.ErrorMessage = "Contracts cannot be added to inactive projects";
                return(retVal);
            }

            var orgCustomer = _cuService.GetCustomerForProject <OrganizationCustomerOutput>(input.ProjectId);

            var providerOrganization = _organizationService.Repository.Queryable()
                                       .Include(x => x.ProviderOrganization)
                                       .Where(x => x.Id == input.ContractorOrganizationId).FirstAsync();

            var orgAccountManager =
                _amService.GetAccountManagerForProject <OrganizationAccountManagerOutput>(input.ProjectId);

            var orgMarketer = project.Customer.OrganizationMarketer;

            var orgContractor = _coService.Repository.Queryable()
                                .Include(x => x.Contractor)
                                .ThenInclude(x => x.OrganizationRecruiter)
                                .ThenInclude(x => x.Organization)
                                .ThenInclude(x => x.RecruitingOrganization)
                                .Include(x => x.Contractor)
                                .ThenInclude(x => x.OrganizationRecruiter)
                                .ThenInclude(x => x.Recruiter)
                                .Where(x => x.ContractorId == input.ContractorId && x.OrganizationId == input.ContractorOrganizationId)
                                .FirstAsync();

            var recruiterStream = orgContractor.Result.Contractor.OrganizationRecruiter.RecruiterStream;

            await Task.WhenAll(
                orgCustomer,
                providerOrganization,
                orgAccountManager,
                orgContractor);

            var nextProviderContractId = await GetNextProviderContractId
                                             (input.ContractorOrganizationId);

            var nextMarketingContractId = await GetNextMarketingContractId
                                              (project.CustomerAccount.Customer.MarketerOrganizationId);

            var nextBuyerContractId = await GetNextBuyerContractId
                                          (orgCustomer.Result.OrganizationId);

            var recruitingAgencyStream = orgContractor.Result.Contractor
                                         .OrganizationRecruiter.Organization.RecruitingOrganization.RecruitingAgencyStream;

            var recruitingAgreement = await _recruitingAgreements.Queryable()
                                      .Where(x => x.RecruitingOrganizationId == orgContractor.Result.Contractor.RecruiterOrganizationId &&
                                             x.ProviderOrganizationId == project.ProjectManagerOrganizationId && x.Status == AgreementStatus.Approved)
                                      .FirstOrDefaultAsync();

            if (recruitingAgreement != null)
            {
                _logger.LogDebug(
                    GetLogMessage("Recruiter agreement found, using agreement values for RE and RAO streams"));

                recruiterStream        = recruitingAgreement.RecruiterStream;
                recruitingAgencyStream = recruitingAgreement.RecruitingAgencyStream;
            }
            else
            {
                _logger.LogDebug(GetLogMessage(
                                     "Recruiter agreement not found, using default values from recruiting org settings"));
            }

            if (orgContractor.Result.Contractor.RecruiterOrganizationId == providerOrganization.Result.Id)
            {
                _logger.LogDebug(GetLogMessage(
                                     "Recruiter organization is same as provider organization, setting RAO stream to 0"));
                recruitingAgencyStream = 0;
            }



            var contract = new Contract()
                           .InjectFrom(input) as Contract;


            // init()
            contract.ProviderNumber   = nextProviderContractId;
            contract.BuyerNumber      = nextBuyerContractId;
            contract.RecruitingNumber = await GetNextRecruitingContractId
                                            (orgContractor.Result.Contractor.RecruiterOrganizationId);

            contract.MarketingNumber = nextMarketingContractId;

            // figure out implicit relationships
            contract.RecruiterOrganizationId = orgContractor.Result.Contractor.RecruiterOrganizationId;
            contract.RecruiterId             = orgContractor.Result.Contractor.RecruiterId;
            contract.MarketerId                   = orgMarketer.MarketerId;
            contract.MarketerOrganizationId       = orgMarketer.OrganizationId;
            contract.AccountManagerOrganizationId = orgAccountManager.Result.OrganizationId;
            contract.ProjectManagerOrganizationId = project.ProjectManagerOrganizationId;
            contract.ContractorOrganizationId     = orgContractor.Result.OrganizationId;
            contract.CustomerId                   = project.CustomerId;
            contract.BuyerOrganizationId          = project.CustomerOrganizationId;


            var agencyStream          = providerOrganization.Result.ProviderOrganization.AgencyStream;
            var accountManagerStream  = orgAccountManager.Result.AccountManagerStream;
            var projectManagerStream  = project.OrganizationProjectManager.ProjectManagerStream;
            var marketingAgencyStream = project.CustomerAccount.MarketingAgencyStream;


            switch (project.Status)
            {
            case ProjectStatus.Pending:
                contract.Status = ContractStatus.Pending;
                break;

            case ProjectStatus.Active:
                contract.Status = ContractStatus.Active;
                break;
            }

            //if (project.CustomerAccount.IsInternal)
            //{
            //    contract.Status = ContractStatus.Active;
            //    agencyStream = 0;

            //    if (project.CustomerAccount.IsCorporate)
            //    {
            //        recruitingAgencyStream = 0;
            //        accountManagerStream = 0;
            //        projectManagerStream = 0;
            //        marketingAgencyStream = 0;
            //    }
            //}

            // determine streams
            contract.AgencyStream           = agencyStream;
            contract.RecruitingAgencyStream = recruitingAgencyStream;
            contract.MarketingAgencyStream  = marketingAgencyStream;
            contract.RecruiterStream        = recruiterStream;
            contract.MarketerStream         = project.CustomerAccount.MarketerStream;

            contract.AccountManagerStream = accountManagerStream;
            contract.ProjectManagerStream = projectManagerStream;
            contract.ContractorStream     = orgContractor.Result.ContractorStream;
            contract.SystemStream         = providerOrganization.Result.ProviderOrganization.SystemStream;

            contract.CreatedById = _userInfo.UserId;
            contract.UpdatedById = _userInfo.UserId;

            contract.AccountManagerId = orgAccountManager.Result.AccountManagerId;
            contract.ProjectManagerId = project.ProjectManagerId;
            contract.ObjectState      = ObjectState.Added;

            contract.StatusTransitions.Add(new ContractStatusTransition()
            {
                Status      = contract.Status,
                ObjectState = ObjectState.Added
            });

            var result = Repository.Insert(contract, true);

            _logger.LogDebug(GetLogMessage("{0} Contract Records updated in database"), result);

            if (result > 0)
            {
                retVal.ContractId = contract.Id;
                retVal.Succeeded  = true;

                await Task.Run(() => RaiseEvent(new ContractCreatedEvent()
                {
                    ContractId = contract.Id
                }));
            }

            return(retVal);
        }
コード例 #13
0
 public Task <ContractResult> CreateContract(IProviderAgencyOwner ao, ContractInput model)
 {
     _logger.LogInformation(GetLogMessage("Creating contract as PAO"));
     model.ContractorOrganizationId = ao.OrganizationId;
     return(CreateContract(model));
 }