コード例 #1
0
        /// <summary>
        /// Handles the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        public void Handle(CompanyGetDetailsCommand command)
        {
            InfoAccumulator info = new InfoAccumulator();
            int             customerId, companyId;

            try {
                customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator);
                companyId  = CompanyIdEncryptor.DecryptCompanyId(command.CompanyId, command.CommandOriginator);
            } catch (Exception ex) {
                Log.Error(ex.Message);
                SendReply(info, command, resp => {
                    resp.CustomerId = command.CustomerId;
                    resp.CompanyId  = command.CompanyId;
                });

                return;
            }

            var company = CompanyQueries.GetCompanyById(companyId)
                          .Value;
            var directors = CompanyQueries.GetDirectors(customerId, companyId)
                            .Value;
            var directorsAddresses = CompanyQueries.GetDirectorsAddresses(customerId, companyId)
                                     .Value;
            var companyEmployeeCount = CompanyQueries.GetCompanyEmployeeCount(customerId, companyId)
                                       .Value;
            var customer = CustomerQueries.GetCustomerPartiallyById(customerId, o => o.PersonalInfo.IndustryType, o => o.PersonalInfo.OverallTurnOver);

            SendReply(info, command, resp => {
                resp.CompanyDetails = ConvertToCompanyDetails(company, customer, companyEmployeeCount);
                resp.Authorities    = GetAuthorities(directors, directorsAddresses);
            });
        }
コード例 #2
0
        public async Task <IActionResult> Get(Guid?id)
        {
            //var company = await _companyService.FindOne(x => x.Id == id);
            var company = await _companyService.FindOne(CompanyQueries.FindById(id));

            return(StatusCode(StatusCodes.Status200OK, new { company }));
        }
コード例 #3
0
        public async Task <IActionResult> Get(string companyName)
        {
            //var companies = await _companyService.Find(x => x.CompanyName.Contains(companyName));
            var companies = await _companyService.Find(CompanyQueries.FindByName(companyName));

            return(StatusCode(StatusCodes.Status200OK, new { companies }));
        }
コード例 #4
0
 public HomeController()
 {
     _context             = new AppointmentsDb.Models.AppointmentsDbContext();
     _unitOfWork          = new AppointmentsDb.Pattern.UnitOfWork(_context);
     _mapper              = new AppointmentsDb.MapperStart.Automapper_Startup().StartAutomapper();
     _professionalQueries = new ProfessionalQueries(_unitOfWork, _mapper);
     _companyQueries      = new CompanyQueries(_unitOfWork, _mapper);
 }
コード例 #5
0
 public CompaniesController(IMessagePipelineService pipelineService, CompanyQueries companyQueries)
 {
     if (pipelineService == null)
     {
         throw new ArgumentNullException(nameof(pipelineService));
     }
     this.pipelineService = pipelineService;
     this.companyQueries  = companyQueries;
 }
コード例 #6
0
        public async Task <IActionResult> Post([FromBody] Company company)
        {
            //if (await _companyService.Exists(x => x.Id == company.Id))
            if (await _companyService.Exists(CompanyQueries.FindById(company.Id.Value)))
            {
                return(StatusCode(StatusCodes.Status406NotAcceptable, new { message = "Company Exists" }));
            }

            var result = await _companyService.Add(company);

            return(StatusCode(StatusCodes.Status201Created, new { company = result }));
        }
コード例 #7
0
        public async Task <IActionResult> Delete([FromBody] Company company)
        {
            //bool exists = await _companyService.Exists(x => x.Id == company.Id);
            bool exists = await _companyService.Exists(CompanyQueries.FindById(company.Id.Value));

            if (!exists)
            {
                return(StatusCode(StatusCodes.Status406NotAcceptable, new { message = "Company not exists" }));
            }

            _companyService.Delete(company);

            return(StatusCode(StatusCodes.Status204NoContent));
        }
コード例 #8
0
        public async Task <IActionResult> Put([FromBody] Company company)
        {
            //bool exists = await _companyService.Exists(x => x.Id == company.Id);
            bool exists = await _companyService.Exists(CompanyQueries.FindById(company.Id.Value));

            if (!exists)
            {
                return(StatusCode(StatusCodes.Status406NotAcceptable, new { message = "Company not exists" }));
            }

            var alteredCompany = await _companyService.Alter(company);

            return(StatusCode(StatusCodes.Status200OK, new { company = alteredCompany }));
        }
コード例 #9
0
        public ProductsController(IMessagePipelineService pipelineService, ProductQueries productQueries, CompanyQueries companyQueries)
        {
            if (pipelineService == null)
            {
                throw new ArgumentNullException(nameof(pipelineService));
            }
            if (productQueries == null)
            {
                throw new ArgumentNullException(nameof(productQueries));
            }

            this.productQueries  = productQueries;
            this.pipelineService = pipelineService;
            this.companyQueries  = companyQueries;
        }
コード例 #10
0
        public void TestCompanyCreation()
        {
            using (var uow = container.Resolve <IAppUnitOfWork>())
            {
                var query  = new CompanyQueries(uow);
                var count1 = query.GetAll().Count();

                var command = new CreateCompanyCommand();
                command.CreatedByUserId = GlobalConfig.AdminId;
                command.Name            = "Test Company " + DateTime.Now.Ticks;

                pipelineService.HandleCommand(command);

                var count2 = query.GetAll().Count();
                Assert.AreEqual(count1 + 1, count2, "number of companies");
            }
        }
コード例 #11
0
        /// <summary>
        /// Gets the companies for hr.
        /// </summary>
        /// <param name="username">The username.</param>
        /// <returns></returns>
        /// <exception cref="ApplicationException">Repository Get All Companies for HR</exception>
        public IList <ICompanyDetail> GetCompaniesForHR(string username)
        {
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var list = CompanyQueries.getCompanyForHRList(dbContext, username).ToList();

                    return(list);
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException("Repository Get All Companies for HR", e);
            }
        }
コード例 #12
0
        /// <summary>
        /// </summary>
        /// <param name="companyId"></param>
        /// <returns></returns>
        /// <exception cref="ApplicationException">Repository getDeductionByCompanyId</exception>
        public IList <ICompanyDetail> getDeductionByCompanyId(int companyId)
        {
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var list = CompanyQueries.getMyCompaniesList(dbContext, companyId).ToList();

                    return(list);
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException("Repository getDeductionByCompanyId", e);
            }
        }
コード例 #13
0
        /// <summary>
        /// Gets the company by cac number.
        /// </summary>
        /// <param name="CACNumber">The cac number.</param>
        /// <returns></returns>
        /// <exception cref="ApplicationException">Repository GetCompanyByCACRegistrationNumber</exception>
        /// <exception cref="System.ApplicationException">Repository GetCompanyByCACRegistrationNumber</exception>
        public ICompanyDetail GetCompanyByCACNumber(string CACNumber)
        {
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var companyInfo = CompanyQueries.getCompanyByCACNumber(dbContext, CACNumber);

                    return(companyInfo);
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException("Repository GetCompanyByCACRegistrationNumber", e);
            }
        }
コード例 #14
0
        /// <summary>
        /// Gets the company by identifier.
        /// </summary>
        /// <param name="companyId">The company identifier.</param>
        /// <returns></returns>
        /// <exception cref="ApplicationException">Repository GetCompanyID</exception>
        public ICompanyDetail GetCompanyById(int companyId)
        {
            try
            {
                using (
                    var dbContext = (HRMSEntities)this.dbContextFactory.GetDbContext(ObjectContextType.HRMS))
                {
                    var companyInfo = CompanyQueries.getCompanyById(dbContext, companyId);

                    return(companyInfo);
                }
            }
            catch (Exception e)
            {
                throw new ApplicationException("Repository GetCompanyID", e);
            }
        }