Ejemplo n.º 1
0
        public ICffClient GetCffClientByClientId(int clientId)
        {
            ICffClient cffClient = null;

            using (SqlConnection connection = CreateConnection())
            {
                using (
                    SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure,
                                                                       "Client_GetClientByCleintID",
                                                                       CreateClientIdParameter(clientId)))
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    if (!cleverReader.IsNull && cleverReader.Read())
                    {
                        if (cleverReader.FromBigInteger("ClientID") == -1)
                        {
                            cffClient = AllClients.Create();
                        }
                        else
                        {
                            cffClient = new CffClient(cleverReader.ToString("ClientName"),
                                                      cleverReader.FromBigInteger("ClientID"),
                                                      cleverReader.FromBigInteger("ClientNum"),
                                                      cleverReader.ToSmallInteger("FacilityType"),
                                                      cleverReader.ToString("CollectionsBankAccount"),
                                                      cleverReader.ToSmallInteger("CFFDebtorAdmin"),        //MSazra [20151006]
                                                      cleverReader.ToBoolean("ClientHasLetterTemplates")    //MSazra [20151006]
                                                      );
                        }
                    }
                }
            }
            return(cffClient);
        }
        public ICffClient LoadCffClientAssociatedWith(ICffUser user)
        {
            ArgumentChecker.ThrowIfNull(user, "user");

            ICffClient client;

            if (user.UserType == UserType.EmployeeAdministratorUser ||
                user.UserType == UserType.EmployeeManagementUser ||
                user.UserType == UserType.EmployeeStaffUser)
            {
                client = AllClients.Create();
            }
            else if (user.UserType == UserType.ClientStaffUser)
            {
                client = clientRepository.GetCffClientByClientId((int)((ClientStaffUser)user).ClientId);
            }
            else if (user.UserType == UserType.ClientManagementUser)
            {
                client = clientRepository.GetCffClientByClientId((int)((ClientManagementUser)user).ClientId);
            }
            else if (user.UserType == UserType.CustomerUser)
            {
                client = clientRepository.GetCffClientByCustomerId((int)((CustomerUser)user).CustomerId);
            }

            else
            {
                throw new CffUserNotFoundException("No cff user found");
            }
            return(client);
        }
Ejemplo n.º 3
0
        public IList <ICffClient> GetClientNameAndNum(string searchString, int numberOfCustomersToReturn)
        {
            IList <ICffClient> clientsList = new List <ICffClient>();

            using (SqlConnection connection = CreateConnection())
            {
                using (
                    SqlDataReader dataReader = SqlHelper.ExecuteReader(connection, CommandType.StoredProcedure,
                                                                       "GetMatchedClient",
                                                                       CreateShowMatchedNamesParameters(searchString,
                                                                                                        numberOfCustomersToReturn))
                    )
                {
                    CleverReader cleverReader = new CleverReader(dataReader);
                    if (!cleverReader.IsNull)
                    {
                        while (cleverReader.Read())
                        {
                            if (cleverReader.FromBigInteger("ClientID") == -1)
                            {
                                clientsList.Add(AllClients.Create());
                            }
                            else
                            {
                                clientsList.Add(new CffClient(cleverReader.ToString("ClientName"),
                                                              cleverReader.FromBigInteger("ClientID"),
                                                              cleverReader.FromBigInteger("ClientNum"),
                                                              cleverReader.ToSmallInteger("FacilityType"),
                                                              cleverReader.ToString("CollectionsBankAccount"),
                                                              cleverReader.ToSmallInteger("CFFDebtorAdmin"),     //MSazra [20151006]
                                                              cleverReader.ToBoolean("ClientHasLetterTemplates") //MSazra [20151006]
                                                              ));
                            }
                        }
                    }
                }
            }

            return(clientsList);
        }
 public bool CheckCustomerBelongsToClient(int clientId, int customerId)
 {
     if (clientId == AllClients.Create().Id)
     {
         return(true);
     }
     using (SqlConnection connection = CreateConnection())
     {
         using (SqlDataReader dataReader = SqlHelper.ExecuteReader(connection,
                                                                   CommandType.StoredProcedure,
                                                                   "CheckCustomerBelongsToClient",
                                                                   CreateClientAndCustomerIdParameters(clientId, customerId)))
         {
             CleverReader cleverReader = new CleverReader(dataReader);
             if (!cleverReader.IsNull && cleverReader.Read())
             {
                 return(cleverReader.ToBoolean("Result"));
             }
         }
     }
     return(false);
 }