Esempio n. 1
0
        public virtual async Task <GetCountResult <TEntity> > Count(GetManyFilter <TEntity> filter)
        {
            IQueryable <TEntity> query = Db.Set <TEntity>();

            query = GenericFilterHelper <TEntity> .GenericFilter(query, filter?.Filters);

            return(await Counter(query));
        }
Esempio n. 2
0
        public virtual async Task <GetCountResult <TEntity> > Count(GetManyFilter <TEntity> filter)
        {
            var result = new GetCountResult <TEntity>();

            try
            {
                var response = await _repository.Count(filter);

                if (response.Success)
                {
                    result.Amount     = response.Amount;
                    result.Success    = true;
                    result.Message    = "OK";
                    result.StatusCode = 200;
                    result.Exception  = null;
                }
                else
                {
                    result.Amount     = null;
                    result.Success    = false;
                    result.Message    = response.Message == "Bad Request" ? "Bad Request" : response.Message;
                    result.StatusCode = response.StatusCode == 400 ? 400 : response.StatusCode;
                    result.Exception  = response.Exception ?? null;
                }
            }
            catch (Exception ex)
            {
                result.Amount     = null;
                result.Success    = false;
                result.Message    = ex.Message;
                result.StatusCode = 500;
                result.Exception  = ex;
            }

            return(result);
        }