예제 #1
0
        /// <summary>
        /// Gets the count.
        /// </summary>
        /// <param name="queryOptions">The query options.</param>
        /// <returns>
        /// Returns counted items
        /// </returns>
        public async Task <IHttpActionResult> GetCount(ODataQueryOptions <Racun> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return(BadRequest(ex.Message));
            }

            var sqlBuilder = new SQLQueryBuilder(queryOptions);

            return(Ok(await stavkaRepository.GetCount(sqlBuilder.ToCountSql())));
        }
예제 #2
0
        // GET: odata/Stavke
        // GET: odata/Stavke?$filter=Cijena+lt+6
        /// <summary>
        /// Gets the stavke.
        /// </summary>
        /// <param name="queryOptions">The query options.</param>
        /// <returns>
        /// Returns all stavke from the database
        /// </returns>
        //  [EnableQuery(AllowedQueryOptions = AllowedQueryOptions.All)]
        public async Task <IHttpActionResult> GetStavke(ODataQueryOptions <Stavka> queryOptions)
        {
            // validate the query.
            try
            {
                queryOptions.Validate(_validationSettings);
            }
            catch (ODataException ex)
            {
                return(BadRequest(ex.Message));
            }

            var sqlBuilder = new SQLQueryBuilder(queryOptions);

            // make $count works
            Request.ODataProperties().TotalCount = await stavkaRepository.GetCount(sqlBuilder.ToCountSql());

            return(Ok(await stavkaRepository.GetAll(sqlBuilder.ToSql())));
        }