public ActionResult List(Models.ReviewSearchModel conditions, int count = 20) { try { var newss = RestfulProductInfo.Search(conditions, 0, count, User.Identity.IsAuthenticated ? User.Identity.Name : null); if (newss == null || newss.Count() < 1) { throw new Exception("NO FOUND"); } return(Json ( new { Entities = RestfulJsonProccessor.ProductInfo.List(newss, User.Identity.IsAuthenticated ? User.Identity.Name : null) }, JsonRequestBehavior.AllowGet )); } catch { Response.StatusCode = 404; return(null); } }
public IEnumerable <Models.Review> Search(Models.ReviewSearchModel conditions = null, int start = 0, int count = 0, string userName = null) { try { return(RestfulProductInfo.Search(conditions, start, count)); } catch { throw; } }
public Models.Review First(Models.ReviewSearchModel conditions = null) { try { return(Search(conditions, 0, 1).First()); } catch { return(null); } }
public Models.Review First(Models.ReviewSearchModel conditions = null, string userName = null) { try { var entity = RestfulProductInfo.First(conditions); if (!ProductInfoAccessControl.Pass(RestfulAction.Read, entity, userName)) { throw new NoAccessException("No Access"); } return(entity); } catch { throw; } }
public IEnumerable <Models.Review> Search(Models.ReviewSearchModel conditions = null, int start = 0, int count = -1) { try { IEnumerable <Models.Review> fs = ( from info in DbEntities.Reviews.OrderByDescending(m => m.Id) where ( ((conditions.IdLower == null || conditions.IdLower < 1) ? true : info.Id < conditions.IdLower) && ((conditions.IdUpper == null || conditions.IdUpper < 1) ? true : info.Id > conditions.IdUpper) && ((conditions.ProductId == null || conditions.ProductId < 1) ? true : info.ProductId == conditions.ProductId) && ( (conditions.Rate == null || conditions.Rate < 1 || conditions.Rate > 5) ? ( ((conditions.RateGT == null || conditions.RateGT < 1 || conditions.RateGT > 5) ? true : info.Rate >= conditions.RateGT) && ((conditions.RateLT == null || conditions.RateLT < 1 || conditions.RateLT > 5) ? true : info.Rate >= conditions.RateLT) ) : info.Rate == conditions.Rate ) && (string.IsNullOrEmpty(conditions.Creator) ? true : info.Creator == conditions.Creator) && ((conditions.Type == null || conditions.Type < 1) ? true : info.Type == conditions.Type) ) select info ).AsEnumerable(); if (start > 0) { fs = fs.Skip(start); } if (count > 0) { fs = fs.Take(count); } for (int i = 0; i < fs.Count(); i++) { var tempT = fs.ElementAt(i); try { GetFullEntity(ref tempT); } catch { ; } } return(fs); } catch { return(null); } }