/// <summary> /// CFDBase constructor /// </summary> public CFDBase() { try { var configurationHelper = ConfigurationHelper.NewInstance; // Update the Configuration Instance if (!configurationHelper.IS_Test_Virtual_Client_Connection && !configurationHelper.IS_Test_BLoyal_Connection) { return; } if (configurationHelper != null && configurationHelper.ENABLE_bLOYAL) { _configurationHelper = configurationHelper; // Update bLoyal Service URL ServiceURLHelper.UpdateServiceURL(); var dinerwareProvider = new DinerwareProvider(); GetTenders(dinerwareProvider); GetDiscountSets(dinerwareProvider, configurationHelper); } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "CFDBase - constructor"); } }
/// <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); }
public DinerwareEngineService.UserCollection GetAllDinerwareUsers() { try { DinerwareProvider objDinerwareProvider = new DinerwareProvider(); return(objDinerwareProvider.GetAllUsers()); } catch (Exception ex) { throw ex; } }
/// <summary> /// Get Tenders /// </summary> /// <param name="dinerwareProvider"></param> private void GetTenders(DinerwareProvider dinerwareProvider) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } TendersCache.Tenders = dinerwareProvider.GetTenders(0); } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "GetTenders"); } }
/// <summary> /// Get Discount Sets /// </summary> /// <param name="dinerwareProvider"></param> /// <param name="configurationHelper"></param> private void GetDiscountSets(DinerwareProvider dinerwareProvider, ConfigurationHelper configurationHelper) { try { if (!ConfigurationHelper.Instance.IS_Test_Virtual_Client_Connection || !ConfigurationHelper.Instance.IS_Test_BLoyal_Connection) { return; } var discountRules = dinerwareProvider.GetAllDiscountRule(); if (discountRules != null && discountRules.Any()) { var bLoyalOrderDiscountType = discountRules.FirstOrDefault(t => t.Name.Equals(configurationHelper.DW_ORDER_LEVEL_DISCOUNT_TYPE_NAME, StringComparison.CurrentCultureIgnoreCase)); if (bLoyalOrderDiscountType != null && bLoyalOrderDiscountType.Active && bLoyalOrderDiscountType.AmountDelta.Equals(0) && !bLoyalOrderDiscountType.IsAutoApplied && bLoyalOrderDiscountType.AppliesToTickets && !bLoyalOrderDiscountType.AppliesToItems && bLoyalOrderDiscountType.AppliesOnAllDays) { int orderDiscountId = 0; int.TryParse(bLoyalOrderDiscountType.TypeID, out orderDiscountId); DiscountSets.OrderLevelDiscountId = orderDiscountId; } var bLoyalItemDiscountType = discountRules.FirstOrDefault(t => t.Name.Equals(configurationHelper.DW_ITEM_LEVEL_DISCOUNT_TYPE_NAME, StringComparison.CurrentCultureIgnoreCase)); if (bLoyalItemDiscountType != null && bLoyalItemDiscountType.Active && bLoyalItemDiscountType.AmountDelta.Equals(0) && !bLoyalItemDiscountType.IsAutoApplied && bLoyalItemDiscountType.AppliesToItems && !bLoyalItemDiscountType.AppliesToTickets && bLoyalItemDiscountType.AppliesOnAllDays) { int itemDiscountId = 0; int.TryParse(bLoyalItemDiscountType.TypeID, out itemDiscountId); DiscountSets.ItemLevelDiscountId = itemDiscountId; } var bLoyalSalePriceDiscountType = discountRules.FirstOrDefault(t => t.Name.Equals(configurationHelper.DW_SALEPRICE_LEVEL_DISCOUNT_TYPE_NAME, StringComparison.CurrentCultureIgnoreCase)); if (bLoyalSalePriceDiscountType != null && bLoyalSalePriceDiscountType.Active && bLoyalSalePriceDiscountType.AmountDelta.Equals(0) && !bLoyalSalePriceDiscountType.IsAutoApplied && bLoyalSalePriceDiscountType.AppliesToItems && !bLoyalSalePriceDiscountType.AppliesToTickets && bLoyalSalePriceDiscountType.AppliesOnAllDays) { int salePriceDiscountId = 0; int.TryParse(bLoyalSalePriceDiscountType.TypeID, out salePriceDiscountId); DiscountSets.ItemLevelSalePriceId = salePriceDiscountId; } } } catch (Exception ex) { _loggerHelper.WriteLogError(ex, "GetDiscountSets"); } }
/// <summary> /// Create Ticket of Dinerware customer in the Dinerware system /// </summary> /// <param name="userId">UserId</param> /// <param name="customer">Customer</param> public void CreateTickets(int userId, wsPerson customer) { try { DinerwareProvider objDinerwareProvider = new DinerwareProvider(); wsTrialTicket objwsTrialTicket = new wsTrialTicket(); objwsTrialTicket.CreateTime = DateTime.UtcNow; if (!string.IsNullOrEmpty(customer.ID)) { objwsTrialTicket.CustomerID = int.Parse(customer.ID); } objwsTrialTicket.TicketName = customer.LNAME + Constants.COMMA_BLANK_SPACE + customer.FNAME; objDinerwareProvider.CreateTickets(userId, objwsTrialTicket); } catch (Exception exception) { throw exception; } }
/// <summary> /// Create Ticket of Dinerware customer in Dinerware system /// </summary> /// <param name="userId">UserId</param> /// <param name="customer">Customer</param> private int CreateTickets(int userId, wsPerson customer, string cartExternalId) { DinerwareProvider objDinerwareProvider = new DinerwareProvider(); try { wsTrialTicket objwsTrialTicket = new wsTrialTicket(); objwsTrialTicket.CreateTime = DateTime.UtcNow; if (!string.IsNullOrWhiteSpace(customer.ID)) { objwsTrialTicket.CustomerID = int.Parse(customer.ID); } objwsTrialTicket.TicketName = $"{customer.LNAME}, {customer.FNAME}"; return(objDinerwareProvider.CreateTickets(userId, objwsTrialTicket, cartExternalId)); } catch (Exception ex) { _logger.WriteLogError(ex, "CreateTickets"); throw ex; } }
/// <summary> /// Find the exiting customer in the dinerware system /// </summary> /// <param name="userId">UserId</param> /// <param name="searchTerm">searchTerm</param> /// <returns>Flag</returns> public bool FindDinerwareCustomer(int userId, string searchTerm) { DinerwareProvider objDinerwareProvider = new DinerwareProvider(); return(objDinerwareProvider.FindDinerwareCustomer(userId, searchTerm)); }