Example #1
0
        public async Task <IEnumerable <CategoryDto> > GetCategories()
        {
            var response = await _categoryProvider.GetAllCategories();

            if (response.Entity == null)
            {
                return(new List <CategoryDto>());
            }
            return(response.Entity.OrderBy(x => x.Name));
        }
Example #2
0
        //[JwtAuthentication]
        public async Task <HttpResponseMessage> GetCategories()
        {
            try
            {
                var categories = await _categoryProvider.GetAllCategories();

                var response = _categoryMapper.Map(categories);
                return(Request.CreateResponse(HttpStatusCode.OK, response));
            }
            catch (Exception err)
            {
                return(Request.CreateResponse(HttpStatusCode.Unauthorized, err.Message));
            }
        }