/// <summary> /// Удаляет из цели правило выбора географической локации /// </summary> /// <param name="target">Цель геолокации</param> /// <param name="location">Географическая локация</param> public void RemoveLocationFromTarget(Target target, Location location) { LocationRule rule = LocationRuleRepository.FindByTargetAndLocation(target, location); if (rule != null) { LocationRuleRepository.Delete(rule); } }
/// <summary> /// Добавляет к цели правило выбора географической локации /// </summary> /// <param name="target">Цель геолокации</param> /// <param name="location">Географическая локация</param> /// <param name="kind">Вид правила включения</param> public void AddLocationToTarget(Target target, Location location, RuleKind kind) { LocationRule rule = LocationRuleRepository.FindByTargetAndLocation(target, location); if (rule == null) { rule = new LocationRule() { TargetId = target.Id, LocationId = location.Id, Kind = kind }; LocationRuleRepository.Create(rule); } else if (rule.Kind != kind) { rule.Kind = kind; LocationRuleRepository.Save(rule); } }