Beispiel #1
0
        public HttpResponseMessage IssueCustomerCard([FromBody] CustomerModel customermodel)
        {
            try
            {
                string errMsg   = string.Empty;
                var    customer = new Customer();
                customer.AccountNumber  = customermodel.AccountNumber;
                customer.CustomerBranch = customermodel.CustomerBranch;
                customer.Downloaded     = false;
                customer.Card           = new CardProductionPL().ProduceCard(customermodel.CardProfileID, Convert.ToInt64(customer.CustomerBranch));

                bool result = CustomerPL.IssueCustomerCard(customer, out errMsg);
                if (string.IsNullOrEmpty(errMsg))
                {
                    return(result.Equals(true) ? Request.CreateResponse(HttpStatusCode.OK, "Card Request was successful.") : Request.CreateResponse(HttpStatusCode.BadRequest, "Request failed"));
                }
                else
                {
                    var response = Request.CreateResponse(HttpStatusCode.BadRequest, errMsg);
                    return(response);
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.WriteError(ex);
                var response = Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message);
                return(response);
            }
        }
        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.");
                }
            }
        }