public IHttpActionResult GetDynamicContent(string store, string[] placeHolders, [FromUri] string[] tags, string language = "en-us") { var tagSet = new TagSet(); if (tags != null) { foreach (var tagArray in tags.Select(tag => tag.Split(new[] { ':' }))) { tagSet.Add(tagArray[0], tagArray[1]); } } // TODO: add tags ?tags={users:[id1,id2]} // TODO: add caching //Mutiple placeholders can be requested var groups = new List <webModel.DynamicContentItemGroup>(); foreach (var holder in placeHolders) { var group = new webModel.DynamicContentItemGroup(holder); var ctx = new DynamicContentEvaluationContext(store, holder, DateTime.Now, tagSet); var results = _contentEvaluator.EvaluateItems(ctx); if (results != null && results.Any()) { group.Items.AddRange(results.Select(x => x.ToWebModel())); groups.Add(group); } } var retVal = new webModel.DynamicContentItemGroupResponseCollection { Items = groups, TotalCount = groups.Count() }; return(this.Ok(retVal)); //return this.StatusCode(HttpStatusCode.NoContent); }
public IHttpActionResult GetDynamicContent(string store, string[] placeHolders, [FromUri] string[] tags, string language = "en-us") { var tagSet = new TagSet(); if (tags != null) { foreach (var tagArray in tags.Select(tag => tag.Split(new[] { ':' }))) { tagSet.Add(tagArray[0], tagArray[1]); } } // TODO: add tags ?tags={users:[id1,id2]} // TODO: add caching //Mutiple placeholders can be requested var groups = new List<webModel.DynamicContentItemGroup>(); foreach (var holder in placeHolders) { var group = new webModel.DynamicContentItemGroup(holder); var ctx = new DynamicContentEvaluationContext(store, holder, DateTime.Now, tagSet); var results = _contentEvaluator.EvaluateItems(ctx); if (results != null && results.Any()) { group.Items.AddRange(results.Select(x => x.ToWebModel())); groups.Add(group); } } var retVal = new webModel.DynamicContentItemGroupResponseCollection { Items = groups, TotalCount = groups.Count() }; return this.Ok(retVal); //return this.StatusCode(HttpStatusCode.NoContent); }