Example #1
0
        /// <summary>
        /// Gets the ids.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="customerId">The customer identifier.</param>
        /// <param name="info">The information.</param>
        /// <param name="companyId">The company identifier.</param>
        /// <returns></returns>
        private bool GetIds(UpdateCompanyCommand command, InfoAccumulator info, out int customerId, out int companyId)
        {
            DateTime date;

            try {
                customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.RequestOrigin, out date);
            } catch (Exception ex) {
                Log.Error(ex.Message);
                info.AddError("Invalid customer id.");
                customerId = -1;
                companyId  = -1;
                return(false);
            }

            try {
                companyId = CompanyIdEncryptor.DecryptCompanyId(command.CustomerId, command.RequestOrigin, out date);
            } catch (Exception ex) {
                Log.Error(ex.Message);
                info.AddError("Invalid company id.");
                customerId = -1;
                companyId  = -1;
                return(false);
            }

            return(true);
        }
        /// <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);
            });
        }
Example #3
0
 /// <summary>
 /// Gets the ids.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="info">The information.</param>
 /// <param name="customerId">The customer identifier.</param>
 /// <param name="companyId">The company identifier.</param>
 /// <param name="authorityId">The authority identifier.</param>
 /// <returns></returns>
 private bool GetIds(CompanyUpdateAuthorityCommand command, InfoAccumulator info, out int customerId, out int companyId, ref int authorityId)
 {
     try {
         customerId = CustomerIdEncryptor.DecryptCustomerId(command.CustomerId, command.CommandOriginator);
         companyId  = CompanyIdEncryptor.DecryptCompanyId(command.CompanyId, command.CommandOriginator);
         if (command.AuhorityId.IsNotEmpty())
         {
             authorityId = AuthorityIdEncryptor.DecryptAuthorityId(command.AuhorityId, command.CommandOriginator, command.Authority.IsDirector);
         }
     } catch (Exception ex) {
         Log.Error(ex.Message);
         info.AddError(ex.Message);
         customerId = -1;
         companyId  = -1;
         return(false);
     }
     return(true);
 }