public ActionResult MiniList(Models.ProductSearchModel conditions, int count = 20) { try { var products = RestfulProduct.Search(conditions, 0, count, User.Identity.IsAuthenticated ? User.Identity.Name : null); if (products == null || products.Count() < 1) { throw new Exception("NO FOUND"); } return(Json ( new { Entities = RestfulJsonProccessor.Product.MiniList(products, User.Identity.IsAuthenticated ? User.Identity.Name : null) }, JsonRequestBehavior.AllowGet )); } catch { Response.StatusCode = 404; return(null); } }
public Models.Product First(Models.ProductSearchModel conditions = null) { try { return(Search(conditions, 0, 1).First()); } catch { return(null); } }
public IEnumerable <Models.Product> Search(Models.ProductSearchModel conditions = null, int start = 0, int count = 0, string userName = null) { try { return(RestfulProduct.Search(conditions, start, count)); } catch { throw; } }
public IEnumerable <Models.Product> Search(Models.ProductSearchModel conditions = null, int start = 0, int count = -1) { try { IEnumerable <Models.Product> fs = ( from product in DbEntities.Products.OrderByDescending(m => m.Id) where ( ((conditions.IdLower == null || conditions.IdLower < 1) ? true : product.Id < conditions.IdLower) && ((conditions.IdUpper == null || conditions.IdUpper < 1) ? true : product.Id > conditions.IdUpper) && ((conditions.VendorId == null || conditions.VendorId < 1) ? true : product.VendorId == conditions.VendorId) && (string.IsNullOrEmpty(conditions.Title) ? true : product.Title.Contains(conditions.Title)) && ((conditions.CategoryId == null || conditions.CategoryId < 1) ? true : product.CategoryId == conditions.CategoryId) && (string.IsNullOrEmpty(conditions.Version) ? true : product.Version == conditions.Version) && (string.IsNullOrEmpty(conditions.Creator) ? true : product.Creator == conditions.Creator) ) select product ).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); } }
public Models.Product First(Models.ProductSearchModel conditions = null, string userName = null) { try { var entity = RestfulProduct.First(conditions); if (!ProductAccessControl.Pass(RestfulAction.Read, entity, userName)) { throw new NoAccessException("No Access"); } return(entity); } catch { throw; } }