public IHttpActionResult Get([FromUri] CustomerCommentRequestModel model) { if (!ModelState.IsValid) { return(Response(new { Success = false })); } if (model.Page <= 0) { model.Page = 1; } if (model.Count <= 0) { model.Count = 5; } //retrieve the comments var comments = _customerCommentService.GetEntityComments(model.EntityId, model.EntityName, model.Page, model.Count); var commentModels = new List <CustomerCommentPublicModel>(); //retrieve all the associated customers at ones for performance reasons var customers = _customerService.GetCustomersByIds(comments.Select(x => x.CustomerId).ToArray()); foreach (var comment in comments) { var cModel = PrepareCommentPublicModel(comment, customers); commentModels.Add(cModel); } //send the response return(Response(new { Success = true, Comments = commentModels })); }