예제 #1
0
        public static List <Object> RetrieveCardRequests(long branchID)
        {
            try
            {
                List <Object> returnedCardRequests = new List <object>();

                List <CardRequest> cardRequests = CustomerDL.RetrieveCardRequest(branchID);

                foreach (CardRequest cardRequest in cardRequests)
                {
                    Object cardRequestObj = new
                    {
                        ID            = cardRequest.ID,
                        CustomerName  = string.Format("{0} {1}", cardRequest.Customer.Lastname, cardRequest.Customer.Othernames),
                        AccountNumber = cardRequest.Customer.AccountNumber,
                        PickupBranch  = cardRequest.Branch.Name,
                        CardType      = cardRequest.CardType,
                        RequestType   = cardRequest.RequestType,
                        RequestStatus = cardRequest.Status,
                        SerialNumber  = cardRequest.SerialNumber,
                        RequestDate   = String.Format("{0:G}", cardRequest.ModifiedDate),
                        Pan           = string.IsNullOrEmpty(cardRequest.EncryptedPan) ? "None" : Crypter.Decrypt(System.Configuration.ConfigurationManager.AppSettings.Get("ekey"), cardRequest.EncryptedPan)
                    };

                    returnedCardRequests.Add(cardRequestObj);
                }

                return(returnedCardRequests);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public int InsertCustomers(Customer customer)
        {
            var customerDL = new CustomerDL();

            //kiem tra loi trung ma
            return(customerDL.Post(customer));
        }
예제 #3
0
        public int UpdateCustomers(Customer customer)
        {
            var customerDL = new CustomerDL();

            customerDL.Put(customer);
            return(1);
        }
예제 #4
0
        public static dynamic SendTokenToCustomer(string accountNumber, string serialNumber)
        {
            try
            {
                dynamic returnedCustomer = new System.Dynamic.ExpandoObject();
                if (!string.IsNullOrEmpty(serialNumber) && ThirdPartyDL.RetrievePanDetailByAccountNumber(serialNumber) == null)
                {
                    throw new Exception(string.Format("Serial Number: {0} is not valid.", serialNumber));
                }
                else
                {
                    Customer customer = CustomerDL.RetrieveCustomerByAccountNumber(accountNumber);
                    if (customer != null)
                    {
                        Random random = new Random();
                        string token  = random.Next(1999, 9999).ToString();
                        returnedCustomer.customerID    = customer.ID;
                        returnedCustomer.customerToken = token;

                        Mail.SendCardRequestToken(customer, token);

                        return(returnedCustomer);
                    }
                    else
                    {
                        throw new Exception(string.Format("Invalid customer with account number: {0}", accountNumber));
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #5
0
 public static bool UpdateCardRequest(long cardRequestID, string requestType, string loggedInUsername)
 {
     try
     {
         string      clearPan    = string.Empty;
         CardRequest cardRequest = new CardRequest();
         if (requestType == StatusUtil.RequestType.WithSerialNumber.ToString())
         {
             List <KioskSolutionLibrary.ModelLibrary.EntityFrameworkLibrary.ThirdPartyData.PANDetail> unusedPans = ThirdPartyDL.RetrieveUnUsedPanDetails();
             if (unusedPans.Count == 0)
             {
                 throw new Exception("There are no available pans for linking");
             }
             else
             {
                 clearPan = unusedPans.Take(1).First().pan;
             }
         }
         bool updated = CustomerDL.UpdateCardRequest(cardRequestID, clearPan, loggedInUsername, out cardRequest);
         if (updated)
         {
             Mail.SendCardPickup(cardRequest);
         }
         return(updated);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #6
0
        public int InsertGroupCustomer(CustomerGroup customerGroup)
        {
            var customerDL = new CustomerDL();

            //kiem tra loi trung ma
            return(customerDL.Post(customerGroup));
        }
예제 #7
0
        public static List <Object> RetrieveCustomers()
        {
            try
            {
                List <Object> returnedCustomers = new List <object>();

                List <Customer> customers = CustomerDL.RetrieveCustomers();

                foreach (Customer customer in customers)
                {
                    Object customerObj = new
                    {
                        ID            = customer.ID,
                        Lastname      = customer.Lastname,
                        Othernames    = customer.Othernames,
                        AccountNumber = customer.AccountNumber,
                        EmailAddress  = customer.EmailAddress,
                        PhoneNumber   = customer.PhoneNumber
                    };

                    returnedCustomers.Add(customerObj);
                }

                return(returnedCustomers);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #8
0
        public Customer GetCustomerByID(Guid customerID)
        {
            var customerDL = new CustomerDL();

            //kiem tra loi trung ma

            return(customerDL.GetById(customerID));
        }
예제 #9
0
        public int DeleteCustomer(Guid customerID)
        {
            var customerDL = new CustomerDL();

            customerDL.Delete(customerID);

            return(1);
        }
예제 #10
0
        public void GetCustomerDetail_KnownUserIsAccessed_ReturnsNotNull()
        {
            //Arrange
            CustomerDL customerDL = new CustomerDL();
            //Act
            Customer result = customerDL.GetCustomerDetail(10000000111);

            //Assert
            Assert.IsNotNull(result);
        }
예제 #11
0
        public void GetCustomerAccounts_KnownUserAccountsAccessed_ReturnsNotNull()
        {
            //Arrange
            CustomerDL customerDL = new CustomerDL();
            //Act
            var result = customerDL.GetCustomerAccount(10000000111);

            //Assert
            Assert.IsNotNull(result);
        }
예제 #12
0
        public void AddCustomer_UserIsAdded_ReturnsTrue()
        {
            //Arrange
            bool       expected   = true;
            CustomerDL customerDL = new CustomerDL();
            //Act
            bool actual = customerDL.AddCustomer("TestCase User", DateTime.Now, 1);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #13
0
        public void GetCustomerDetail_UnKnownUserIsAccessed_ReturnsFalse()
        {
            //Arrange
            Customer   expected   = null;
            CustomerDL customerDL = new CustomerDL();
            //Act
            Customer actual = customerDL.GetCustomerDetail(999999999999999999);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #14
0
        public void UpdateCustomer_UnKnownUserIsUpdated_ReturnsFalse()
        {
            //Arrange
            bool       expected   = false;
            CustomerDL customerDL = new CustomerDL();
            //Act
            bool actual = customerDL.UpdateCustomer(999999999999999999, "TestCase First", DateTime.Now, 1);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #15
0
        public void UpdateCustomer_KnownUserIsUpdated_ReturnsTrue()
        {
            //Arrange
            bool       expected   = true;
            CustomerDL customerDL = new CustomerDL();
            //Act
            bool actual = customerDL.UpdateCustomer(10000000111, "TestCase User", DateTime.Today, 1);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #16
0
        public void AddCustomer_UserTryingToAddInUnKnownBranch_ReturnsFalse()
        {
            //Arrange
            bool       expected   = false;
            CustomerDL customerDL = new CustomerDL();
            //Act
            bool actual = customerDL.AddCustomer("TestCase User", DateTime.Now, 7);

            //Assert
            Assert.AreEqual(expected, actual);
        }
예제 #17
0
 public static bool Update(Customer customer)
 {
     try
     {
         return(CustomerDL.Update(customer));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #18
0
        public HttpResponseMessage GetCredit(string custKey, int amount)
        {
            CustomerDL dataaccess = new CustomerDL();
            bool       result     = dataaccess.GetCustomerCredit(Guid.Parse(custKey), amount);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Credit Approved"));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK, "Credit Denied"));
            }
        }
예제 #19
0
        //-----------------------------------------------------------------------------------
        //----------------------- get Account Details using Account Number ------------------

        public static Customer GetCustomerByAccountNumber(string accountNumber)
        {
            Customer customerObj = null;

            try
            {
                customerObj = CustomerDL.GetCustomerByAccountNumber(accountNumber);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error : CustomerBL:GetCustomerByAccountNumber : " + ex.Message.ToString());
            }
            return(customerObj);
        }
예제 #20
0
        //------------------------------------------------------------------------------------
        //----------------------- Delete Customer Account ------------------------------------

        public static int DeleteAccountDetails(string accountNumber)
        {
            int output = 0;

            try
            {
                output = CustomerDL.DeleteAccountDetails(accountNumber);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("******Error:CustomerBL.cs:DeleteAccountDetails" + ex.Message.ToString());
            }
            return(output);
        }
예제 #21
0
        //-----------------------------------------------------------------------------------------
        //----------------- Insert New Customer Details -------------------------------------------

        public static int InsertCustomerDetails(Customer objCustomer)
        {
            int output = 0;

            try
            {
                output = CustomerDL.InsertCustomerDetails(objCustomer);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("******Error:CustomerBL.cs:InsertCustomerDetails" + ex.Message.ToString());
            }

            return(output);
        }
예제 #22
0
        public string RegisterCustomer(ClientCustomerModel customermodel)
        {
            string persoData = "";

            string errMsg = string.Empty;

            var customer = new Customer();

            customer.AccountNumber  = customermodel.AccountNumber;
            customer.Date           = System.DateTime.Now;
            customer.CustomerBranch = customermodel.CustomerBranch;
            customer.Downloaded     = customermodel.Downloaded;
            customer.Card           = new CardProductionPL().ProduceCard(customermodel.CardProfileID, Convert.ToInt64(customer.CustomerBranch));

            bool result = CustomerPL.IssueCustomerCard(customer, out errMsg);

            if (result)
            {
                if (string.IsNullOrEmpty(errMsg))
                {
                    var theCustomer = CustomerDL.RetrieveCustomer(customer.AccountNumber);

                    customer.Surname    = theCustomer.Surname;
                    customer.Othernames = theCustomer.Othernames;

                    var customers = new List <Customer>();
                    customers.Add(customer);

                    persoData = CustomerPL.FormatCustomerPersoDataForDownload(customers);
                    return(persoData);
                }
                else
                {
                    throw new Exception(errMsg);
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(errMsg))
                {
                    throw new Exception(errMsg);
                }
                else
                {
                    throw new Exception("Customer Registration Failed.");
                }
            }
        }
예제 #23
0
        public static bool SaveCardRequest(CardRequest cardRequest, string username)
        {
            try
            {
                CardRequest savedCardRequest = new CardRequest();

                bool saved = CustomerDL.SaveCardRequest(cardRequest, username, out savedCardRequest);
                if (saved)
                {
                    Mail.SendCardPickup(savedCardRequest);
                }
                return(saved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #24
0
 public static bool Save(Customer customer, out string message)
 {
     try
     {
         if (CustomerDL.CustomerExists(customer))
         {
             message = string.Format("Customer with email address: {0} exists already", customer.EmailAddress);
             return(false);
         }
         else
         {
             message = string.Empty;
             return(CustomerDL.Save(customer));
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #25
0
        //------------------------------------------------------------------------------------------
        //------------- Get Last Customer Id for generating new Customer Id for customers ----------

        public static string GetNewCustomerId()
        {
            string lastCustomerId = null;
            string newCustomerId  = null;

            try
            {
                lastCustomerId = CustomerDL.GetLastCustomerId();
                if (lastCustomerId != null)
                {
                    newCustomerId = UtilityHelper.GenerateCustomerId(lastCustomerId);
                }
                else
                {
                    newCustomerId = "1001";
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error : CustomerBL : GetNewCustomerId() " + ex.Message.ToString());
            }
            return(newCustomerId);
        }
예제 #26
0
        //------------------------------------------------------------------------------------------
        //------------- Get Last Account No for generating new account No for customers ------------

        public static string GetNewAccountNumber()
        {
            string lastAccountNumber = null;
            string newAccountNumber  = null;

            try
            {
                lastAccountNumber = CustomerDL.GetLastAccountNumber();
                if (lastAccountNumber != null)
                {
                    newAccountNumber = UtilityHelper.GenerateAccountNumber(lastAccountNumber);
                }
                else
                {
                    newAccountNumber = "100001";
                }
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine("Error : CustomerBL : GetNewAccountNumber() " + ex.Message.ToString());
            }
            return(newAccountNumber);
        }
예제 #27
0
 public static void DeleteCustomer(long id)
 {
     CustomerDL.DeleteCustomer(id);
 }
예제 #28
0
 public static void UpdateCustomer(Customer customer)
 {
     CustomerDL.UpdateCustomer(customer);
 }
예제 #29
0
 public static void AddCustomer(Customer customer)
 {
     CustomerDL.AddCustomer(customer);
 }
예제 #30
0
        public List <Customer> GetCustomers()
        {
            var customerDL = new CustomerDL();

            return(customerDL.Get());
        }