Пример #1
0
 public CategoryViewModel BuildViewModel(int?id = null)
 {
     if (id.HasValue)
     {
         var category = _categoryRepository.GetBy(id.Value);
         return(_mapper.Map(category));
     }
     return(new CategoryViewModel());
 }
Пример #2
0
        public CategoriesViewModel BuildViewModel()
        {
            var categories = _categoryRepository.GetAll()
                             .Select(category => _mapper.Map(category));

            return(new CategoriesViewModel
            {
                Categories = categories
            });
        }
Пример #3
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));
            }
        }
Пример #4
0
        private IEnumerable <CategoryViewModel> GetElectedCategories(int?id)
        {
            var gameCategories = _gameRepository.GetAllCategoriesBy(id ?? 0);

            return(gameCategories.Select(c => _categoryMapper.Map(c)));
        }