public CategoryViewModel BuildViewModel(int?id = null) { if (id.HasValue) { var category = _categoryRepository.GetBy(id.Value); return(_mapper.Map(category)); } return(new CategoryViewModel()); }
public CategoriesViewModel BuildViewModel() { var categories = _categoryRepository.GetAll() .Select(category => _mapper.Map(category)); return(new CategoriesViewModel { Categories = categories }); }
//[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)); } }
private IEnumerable <CategoryViewModel> GetElectedCategories(int?id) { var gameCategories = _gameRepository.GetAllCategoriesBy(id ?? 0); return(gameCategories.Select(c => _categoryMapper.Map(c))); }