/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="querySettings"></param> /// <param name="count"></param> /// <returns></returns> public static Helpers.ActionResult Count(Helpers.ApiContext apiContext, Helpers.QuerySettings <Entities.ImageType> querySettings, out int count) { // TODO: Perform QuerySettings Sort Expression validation here (Match SortColumn type with TType) // TODO: Perform QuerySettings Where Expression validation here (Match Expression; Add Default Where Expr) // API doesn't allow null parameters. if (apiContext == null) { throw new System.ArgumentNullException("apiContext"); } if (querySettings == null) { throw new System.ArgumentNullException("querySettings"); } // Verify user is authorized to perform action, otherwise throw exception. Security.SecurityHandler.SetApiContext(apiContext); Helpers.ActionResult result = Helpers.ActionResult.Factory(true); try { Model.OrmsContext context = (Model.OrmsContext)apiContext.CurrentContext; // execute the query with query settings applied count = context.ImageTypes.Where(querySettings.GetWhereExpression()).Count(); } catch (System.Exception ex) { object forDebugging = ex; throw; // Helpers.Exceptions.GetEntityException.Factory(ex); } return(result); }
/// <summary> /// No Metadata Documentation available. /// </summary> /// <param name="apiContext"></param> /// <param name="querySettings"></param> /// <param name="imageTypes"></param> /// <returns></returns> public static Helpers.ActionResult Get(Helpers.ApiContext apiContext, Helpers.QuerySettings <Entities.ImageType> querySettings, out System.Collections.Generic.List <Entities.ImageType> imageTypes) { // API doesn't allow null parameters. if (apiContext == null) { throw new System.ArgumentNullException("apiContext"); } if (querySettings == null) { throw new System.ArgumentNullException("querySettings"); } // Verify user is authorized to perform action, otherwise throw exception. Security.SecurityHandler.SetApiContext(apiContext); Helpers.ActionResult result = Helpers.ActionResult.Factory(true); try { Model.OrmsContext context = (Model.OrmsContext)apiContext.CurrentContext; // make entities query and set the NoTracking option to stop tracking of entities by entity framework System.Data.Objects.ObjectQuery <Entities.ImageType> query = context.ImageTypes; query.MergeOption = System.Data.Objects.MergeOption.NoTracking; // include entities foreach (System.String include in querySettings.IncludedEntities) { query = query.Include(include); } // execute the query with query settings applied imageTypes = query .Where(querySettings.GetWhereExpression()) .OrderBy(querySettings.SortExpression) .Skip(querySettings.ResultsStartIndex) .Take(querySettings.MaxResultsSize) .ToList(); } catch (System.Exception ex) { object forDebugging = ex; throw; // Helpers.Exceptions.GetEntityException.Factory(ex); } return(result); }