예제 #1
0
        /// <summary>
        /// Add the bLoyal customer to dinerware system with Create ticket
        /// </summary>
        /// <param name="userId">userId</param>
        /// <param name="customer">customer</param>
        /// <returns>Response</returns>
        public int AddCustomerToDinerware(int userId, wsPerson customer)
        {
            int addCustomerResponse = 0;

            try
            {
                DinerwareProvider objDinerwareProvider = new DinerwareProvider();

                string searchTerm = customer.LNAME + Constants.BLANK_SPACE + customer.FNAME;
                bool   flag       = FindDinerwareCustomer(userId, searchTerm);
                //Create customer in the dinerware
                if (flag)
                {
                    addCustomerResponse = objDinerwareProvider.AddCustomer(userId, customer);
                    // Create ticket
                    CreateTickets(userId, customer);
                    return(addCustomerResponse);
                }
                else
                {
                    // Create ticket
                    CreateTickets(userId, customer);
                }
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(addCustomerResponse);
        }
예제 #2
0
        /// <summary>
        /// Add bLoyal customer to dinerware system with Create new ticket
        /// </summary>
        /// <param name="userId">userId</param>
        /// <param name="customer">customer</param>
        /// <returns>Response</returns>
        public TicketResponse AddCustomerToDinerware(int userId, bLoyal.Connectors.LoyaltyEngine.Customer transactionCustomer, string cartExternalId = "")
        {
            try
            {
                wsPerson[] arryWsPerson = null;
                int        customerId   = 0;
                wsPerson   dwWSPerson   = new wsPerson {
                    FNAME = transactionCustomer.FirstName, LNAME = transactionCustomer.LastName, PHONE = transactionCustomer.Phone1, ADDRESS1 = transactionCustomer.Address.Address1, ADDRESS2 = transactionCustomer.Address.Address2, CITY = transactionCustomer.Address.City, STATE = transactionCustomer.Address.StateCode, POSTAL = transactionCustomer.Address.PostalCode, ID = transactionCustomer.Id.ToString(), EMAIL = transactionCustomer.EmailAddress
                };

                if (transactionCustomer.BirthDate.HasValue)
                {
                    dwWSPerson.DOB = transactionCustomer.BirthDate.Value;
                }

                if (!string.IsNullOrWhiteSpace(transactionCustomer.ExternalId))
                {
                    int.TryParse(transactionCustomer.ExternalId, out customerId);
                    if (customerId != 0)
                    {
                        var wsPerson = _dinerwareProvider.GetCustomerById(userId, customerId);
                        if (wsPerson == null)
                        {
                            customerId = 0;
                        }
                    }
                }

                if (customerId == 0 && !string.IsNullOrWhiteSpace(dwWSPerson.EMAIL))
                {
                    arryWsPerson = _dinerwareProvider.IsDinerwareCustomerAvailable(userId, dwWSPerson.EMAIL);
                    if (arryWsPerson != null && arryWsPerson.Length > 0)
                    {
                        int.TryParse(arryWsPerson[0].ID, out customerId);
                    }
                }

                if (customerId == 0)
                {
                    customerId = _dinerwareProvider.AddCustomer(userId, dwWSPerson);
                }
                else
                {
                    dwWSPerson.ID = customerId.ToString();
                    int customerID = _dinerwareProvider.UpdateCustomer(userId, dwWSPerson);
                }

                int ticketId = 0;

                if (customerId != 0)
                {
                    dwWSPerson.ID = customerId.ToString();
                    // Create ticket
                    ticketId = CreateTickets(userId, dwWSPerson, cartExternalId);
                }
                return(new TicketResponse {
                    CustomerId = customerId, TicketId = ticketId
                });
            }
            catch (Exception ex)
            {
                _logger.WriteLogError(ex, "AddCustomerToDinerware");
            }
            return(null);
        }