public void SaveCurrentScoreAlgorythm(CurrentScoreAlgorythm currentScoreAlgorythm) { if (Repository.FirstOrDefault(r => r.ItemType == currentScoreAlgorythm.ItemType) != null) Repository.First(r => r.ItemType == currentScoreAlgorythm.ItemType).Name = currentScoreAlgorythm.Name; else Repository.Add(currentScoreAlgorythm); }
public ActionResult ChangeRules(string id, string ruleName) { ItemType currentItemType; if (!Enum.TryParse<ItemType>(id, true, out currentItemType)) throw new ArgumentException("argument id is not an ItemType"); CurrentScoreAlgorythm rule = new CurrentScoreAlgorythm { ItemType = currentItemType, Name = ruleName }; IAlgorythmPoolProvider alg = ClientFactory.GetClient<IAlgorythmPoolProvider>(); var noOfItems = alg.SetRule(rule); ITopRecordProvider topTotalsProvider = ClientFactory.GetClient<ITopRecordProvider>(); topTotalsProvider.ClearAll(currentItemType); return Json(noOfItems, JsonRequestBehavior.AllowGet); }
public void SaveCurrentScoreAlgorythm(CurrentScoreAlgorythm currentScoreAlgorythm) { var existingSettings = ListCurrentScoreAlgorythms(); if (existingSettings.FirstOrDefault(r => r.ItemType == currentScoreAlgorythm.ItemType) != null) existingSettings.First(r => r.ItemType == currentScoreAlgorythm.ItemType).Name = currentScoreAlgorythm.Name; else existingSettings.Add(currentScoreAlgorythm); var fileFullPath = ConfigurationManager.AppSettings["SettingsFile"]; Utility.SerializeToFile(existingSettings, fileFullPath); }
public int SetRule(CurrentScoreAlgorythm rule) { ISimulationCRUD simulationCRUD = ClientFactory.GetClient<ISimulationCRUD>(); simulationCRUD.SaveCurrentScoreAlgorythm(rule); return GetCurrentAlgorythm(rule.ItemType).NoOfItemsConsidered; }