public void DeleteProgramCondition(ProgramCondition condition) { if (condition == null) { throw new ArgumentNullException("condition"); } _programConditionRepository.Delete(condition); _eventPublisher.EntityDeleted(condition); }
public void InsertProgramCondition(ProgramCondition condition) { if (condition == null) { throw new ArgumentNullException("condition"); } _programConditionRepository.Insert(condition); _eventPublisher.EntityInserted(condition); }
public ActionResult Index() { AffiliateProgram program = new AffiliateProgram(); ProgramCondition condition = new ProgramCondition(); condition.Name = "CartTotal"; condition.Operation = LogicalOperation.Is; condition.Value = "10"; condition.AffiliateProgram = program; //_affiliateProgramService.InsertAffiliateProgram(program); //_affiliateProgramService.InsertProgramCondition(condition); program = _affiliateProgramService.GetAffiliateProgramById(1); Order order = new Order { OrderTotal = 10 }; var cart = _workContext.CurrentCustomer.ShoppingCartItems .Where(sci => sci.ShoppingCartType == ShoppingCartType.ShoppingCart) .LimitPerStore(_storeContext.CurrentStore.Id) .ToList(); decimal orderSubTotalDiscountAmountBase; Discount orderSubTotalAppliedDiscount; decimal subTotalWithoutDiscountBase; decimal subTotalWithDiscountBase; var subTotalIncludingTax = _workContext.TaxDisplayType == TaxDisplayType.IncludingTax && !_taxSettings.ForceTaxExclusionFromOrderSubtotal; _orderTotalCalculationService.GetShoppingCartSubTotal(cart, subTotalIncludingTax, out orderSubTotalDiscountAmountBase, out orderSubTotalAppliedDiscount, out subTotalWithoutDiscountBase, out subTotalWithDiscountBase); decimal subtotalBase = subTotalWithoutDiscountBase; decimal subtotal = _currencyService.ConvertFromPrimaryStoreCurrency(subtotalBase, _workContext.WorkingCurrency); var subTotal = _priceFormatter.FormatPrice(subtotal, true, _workContext.WorkingCurrency, _workContext.WorkingLanguage, subTotalIncludingTax); //_affiliateProgramService.VerifyQualificaion(program, order); var valueType = "qwer".GetType().IsValueType; var ans = CompareReferenceTypes <string, string> ("<=", "15.", "12.33"); //_shoppingCartService. return(View()); }
private bool VerifyCondition(ProgramCondition c) { bool returnValue = false; string comparisonValue = c.ComparisonValue; // if (c.Domain == Domains.HomeAutomation_HomeGenie && c.Target == "Automation" && (c.Property == "Scheduler.TimeEvent" || c.Property == "Scheduler.CronEvent")) { return homegenie.ProgramManager.SchedulerService.IsScheduling(c.ComparisonValue); } // // if the comparison value starts with ":", then the value is read from another module property // eg: ":HomeAutomation.X10/B3/Level" if (comparisonValue.StartsWith(":")) { string[] propertyPath = comparisonValue.Substring(1).Split('/'); comparisonValue = ""; if (propertyPath.Length >= 3) { string domain = propertyPath[0]; string address = propertyPath[1]; string propertyName = propertyPath[2]; var targetModule = homegenie.Modules.Find(m => m.Domain == domain && m.Address == address); if (targetModule == null) { // abbreviated path, eg: ":X10/B3/Level" targetModule = homegenie.Modules.Find(m => m.Domain.EndsWith("." + domain) && m.Address == address); } // if (targetModule != null) { var mprop = Utility.ModuleParameterGet(targetModule, propertyName); if (mprop != null) { comparisonValue = mprop.Value; } } } } // // the following "Programs.*" parameters are deprecated, just left for compatibility with HG < r340 // Also the target "Automation" is deprecated and left for compatibility with HG < 499 // ModuleParameter parameter = null; if (c.Domain == Domains.HomeAutomation_HomeGenie && (c.Target == SourceModule.Scheduler || c.Target == "Automation")) { parameter = new ModuleParameter(); parameter.Name = c.Property; switch (parameter.Name) { case "Programs.DateDay": case "Scheduler.DateDay": parameter.Value = DateTime.Now.Day.ToString(); break; case "Programs.DateMonth": case "Scheduler.DateMonth": parameter.Value = DateTime.Now.Month.ToString(); break; case "Programs.DateDayOfWeek": case "Scheduler.DateDayOfWeek": parameter.Value = ((int)DateTime.Now.DayOfWeek).ToString(); break; case "Programs.DateYear": case "Scheduler.DateYear": parameter.Value = DateTime.Now.Year.ToString(); break; case "Programs.DateHour": case "Scheduler.DateHour": parameter.Value = DateTime.Now.Hour.ToString(); break; case "Programs.DateMinute": case "Scheduler.DateMinute": parameter.Value = DateTime.Now.Minute.ToString(); break; case "Programs.Date": case "Scheduler.Date": parameter.Value = DateTime.Now.ToString("YY-MM-dd"); break; case "Programs.Time": case "Scheduler.Time": parameter.Value = DateTime.Now.ToString("HH:mm:ss"); break; case "Programs.DateTime": case "Scheduler.DateTime": parameter.Value = DateTime.Now.ToString("YY-MM-dd HH:mm:ss"); break; //default: // Module module = homegenie.Modules.Find(m => m.Address == c.Target && m.Domain == c.Domain); // if (module != null) // parameter = module.Properties.Find(mp => mp.Name == c.Property); // break; } } else { Module module = homegenie.Modules.Find(m => m.Address == c.Target && m.Domain == c.Domain); if (module != null) parameter = module.Properties.Find(mp => mp.Name == c.Property); } if (parameter != null) { IComparable lvalue = parameter.Value; IComparable rvalue = comparisonValue; // double dval = 0; DateTime dtval = new DateTime(); // if (double.TryParse(parameter.Value.Replace(",", "."), NumberStyles.Float | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out dval)) { lvalue = dval; rvalue = double.Parse(comparisonValue.Replace(",", "."), NumberStyles.Float | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture); } else if (DateTime.TryParse(parameter.Value, out dtval)) { lvalue = dtval; rvalue = DateTime.Parse(comparisonValue); } // int comparisonresult = lvalue.CompareTo(rvalue); if (c.ComparisonOperator == ComparisonOperator.LessThan && comparisonresult < 0) { returnValue = true; } else if (c.ComparisonOperator == ComparisonOperator.Equals && comparisonresult == 0) { returnValue = true; } else if (c.ComparisonOperator == ComparisonOperator.GreaterThan && comparisonresult > 0) { returnValue = true; } } return returnValue; }
private bool VerifyCondition(ProgramCondition c) { bool returnValue = false; string comparisonValue = c.ComparisonValue; // if (c.Domain == Domains.HomeAutomation_HomeGenie && c.Target == "Automation" && (c.Property == "Scheduler.TimeEvent" || c.Property == "Scheduler.CronEvent")) { return(homegenie.ProgramManager.SchedulerService.IsScheduling(c.ComparisonValue)); } // // if the comparison value starts with ":", then the value is read from another module property // eg: ":HomeAutomation.X10/B3/Level" if (comparisonValue.StartsWith(":")) { string[] propertyPath = comparisonValue.Substring(1).Split('/'); comparisonValue = ""; if (propertyPath.Length >= 3) { string domain = propertyPath[0]; string address = propertyPath[1]; string propertyName = propertyPath[2]; var targetModule = homegenie.Modules.Find(m => m.Domain == domain && m.Address == address); if (targetModule == null) { // abbreviated path, eg: ":X10/B3/Level" targetModule = homegenie.Modules.Find(m => m.Domain.EndsWith("." + domain) && m.Address == address); } // if (targetModule != null) { var mprop = Utility.ModuleParameterGet(targetModule, propertyName); if (mprop != null) { comparisonValue = mprop.Value; } } } } // // the following "Programs.*" parameters are deprecated, just left for compatibility with HG < r340 // Also the target "Automation" is deprecated and left for compatibility with HG < 499 // ModuleParameter parameter = null; if (c.Domain == Domains.HomeAutomation_HomeGenie && (c.Target == SourceModule.Scheduler || c.Target == "Automation")) { parameter = new ModuleParameter(); parameter.Name = c.Property; switch (parameter.Name) { case "Programs.DateDay": case "Scheduler.DateDay": parameter.Value = DateTime.Now.Day.ToString(); break; case "Programs.DateMonth": case "Scheduler.DateMonth": parameter.Value = DateTime.Now.Month.ToString(); break; case "Programs.DateDayOfWeek": case "Scheduler.DateDayOfWeek": parameter.Value = ((int)DateTime.Now.DayOfWeek).ToString(); break; case "Programs.DateYear": case "Scheduler.DateYear": parameter.Value = DateTime.Now.Year.ToString(); break; case "Programs.DateHour": case "Scheduler.DateHour": parameter.Value = DateTime.Now.Hour.ToString(); break; case "Programs.DateMinute": case "Scheduler.DateMinute": parameter.Value = DateTime.Now.Minute.ToString(); break; case "Programs.Date": case "Scheduler.Date": parameter.Value = DateTime.Now.ToString("YY-MM-dd"); break; case "Programs.Time": case "Scheduler.Time": parameter.Value = DateTime.Now.ToString("HH:mm:ss"); break; case "Programs.DateTime": case "Scheduler.DateTime": parameter.Value = DateTime.Now.ToString("YY-MM-dd HH:mm:ss"); break; //default: // Module module = homegenie.Modules.Find(m => m.Address == c.Target && m.Domain == c.Domain); // if (module != null) // parameter = module.Properties.Find(mp => mp.Name == c.Property); // break; } } else { Module module = homegenie.Modules.Find(m => m.Address == c.Target && m.Domain == c.Domain); if (module != null) { parameter = module.Properties.Find(mp => mp.Name == c.Property); } } if (parameter != null) { IComparable lvalue = parameter.Value; IComparable rvalue = comparisonValue; // double dval = 0; DateTime dtval = new DateTime(); // if (double.TryParse(parameter.Value.Replace(",", "."), NumberStyles.Float | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out dval)) { lvalue = dval; rvalue = double.Parse(comparisonValue.Replace(",", "."), NumberStyles.Float | NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture); } else if (DateTime.TryParse(parameter.Value, out dtval)) { lvalue = dtval; rvalue = DateTime.Parse(comparisonValue); } // int comparisonresult = lvalue.CompareTo(rvalue); if (c.ComparisonOperator == ComparisonOperator.LessThan && comparisonresult < 0) { returnValue = true; } else if (c.ComparisonOperator == ComparisonOperator.Equals && comparisonresult == 0) { returnValue = true; } else if (c.ComparisonOperator == ComparisonOperator.GreaterThan && comparisonresult > 0) { returnValue = true; } } return(returnValue); }