public static TCriteria MapTo <TCriteriaSetEntity, TCriteriaEntity, TCriteria>(this TCriteriaSetEntity entity, string type, ICriteriaPersister criteriaPersister, bool persistantIsString) where TCriteriaSetEntity : ICriteriaSetEntity <TCriteriaEntity> where TCriteriaEntity : class, ICriteriaEntity where TCriteria : Criteria { // Create first. var criteria = criteriaPersister.CreateCriteria <TCriteria>(type); criteria.Id = entity.id; criteriaPersister.OnLoading(criteria); foreach (var criteriaEntity in entity.Entities) { try { criteria.SetPersistantItem(criteriaEntity.name, criteriaEntity.value, persistantIsString); } catch (Exception ex) { throw new ApplicationException("Could not set the criteria item with name '" + criteriaEntity.name + "'.", ex); } } criteriaPersister.OnLoaded(criteria); return(criteria); }
public static Criteria Map(this CampaignEntity entity, CampaignCriteriaSetEntity criteriaSetEntity, ICriteriaPersister criteriaPersister) { var type = ((CampaignCategory)entity.category).ToString(); return(criteriaSetEntity == null ? criteriaPersister.CreateCriteria(type) : criteriaSetEntity.MapTo <CampaignCriteriaSetEntity, CampaignCriteriaEntity, Criteria>(type, criteriaPersister, false)); }
private Criteria CreateCriteria(string type) { if (type == CampaignCategory.Employer.ToString()) { return(_employerPersister.CreateCriteria()); } return(_memberPersister.CreateCriteria(type)); }