public async Task <ActionResult <IEnumerable <CardResponse> > > GetCards() { var cards = await _cardRepository.GetAll(); var cardResponses = MapModelToResponse(cards); return(cardResponses); }
public static IList<Card> ListAllCards() { using (ICardRepository cardRepository = new CardRepository()) { IQueryable<Card> query = cardRepository.GetAll<Card>(); query = cardRepository.IncludeAllRelations(query); return query.ToList(); } }
public IHttpActionResult GetAll() { try { var dbCardEntities = _cardRepository.GetAll().ToList(); // it doesn't make much sense to map here as vm and db objects are equivalent //but a good practice says that it is generally not advisable to return db objects to the front end var vmCards = Mapper.Map <List <CardViewModel> >(dbCardEntities); var result = DataManipulationHelper.ParseListOfCardsToDictionaryByStatuses(vmCards); return(Ok(result)); } catch (Exception e) { _logger.Error("Could not retrieve cards. Exception Message: " + e.Message); return(BadRequest("Could not retrieve cards")); } }
private void InitFilter() { ComplexFilterParams = new StockUnitFilterParams(); var statusRepository = new StatusRepository(); var ownerRepository = new OwnerRepository(); var cardRepository = new CardRepository(); var filterStatusList = statusRepository.GetAll(status => status.StatusType); var filterOwnerList = ownerRepository.GetAll(owner => owner.Name.DisplayName); var filterCardList = cardRepository.GetAll(card => card.CardName); _filterOwnerCheckList = new ObservableCollection <CheckBoxItem <Owner> >(); foreach (var owner in filterOwnerList) { FilterOwnerCheckList.Add(new CheckBoxItem <Owner> { Item = owner }); } OnPropertyChanged("FilterOwnerCheckList"); _filterStatusCheckList = new ObservableCollection <CheckBoxItem <Status> >(); foreach (var status in filterStatusList) { FilterStatusCheckList.Add(new CheckBoxItem <Status> { Item = status }); } OnPropertyChanged("FilterStatusCheckList"); _filterCardCheckList = new ObservableCollection <CheckBoxItem <Card> >(); foreach (var card in filterCardList) { FilterCardCheckList.Add(new CheckBoxItem <Card> { Item = card }); } OnPropertyChanged("FilterCardCheckList"); }
public static void Main() { var list = new List <Card>() { new Card() { SourceId = "Мельбурн", DestinationId = "Кельн" }, new Card() { SourceId = "Москва", DestinationId = "Париж" }, new Card() { SourceId = "Кельн", DestinationId = "Москва" } }; var repository = new CardRepository(); foreach (var card in list) { repository.Add(card); } var cards = repository.GetAll().ToArray(); Debug.Assert(cards.Length == 3); Debug.Assert(cards[0].SourceId == "Мельбурн"); Debug.Assert(cards[0].DestinationId == "Kельн"); Debug.Assert(cards[1].SourceId == "Kельн"); Debug.Assert(cards[1].DestinationId == "Москва"); Debug.Assert(cards[2].SourceId == "Москва"); Debug.Assert(cards[2].DestinationId == "Париж"); // The complexity of the sort algorithm would be measured as O(n + k) = O(n) }
public static IList<Satellite> ListAllSatellites() { using (ICardRepository cardRepository = new CardRepository()) { return cardRepository.GetAll<Satellite>().ToList(); } }
public static IList<CardGroup> ListAllCardGroups() { using (ICardRepository cardRepository = new CardRepository()) { var listAllCardGroups = cardRepository.GetAll<CardGroup>().ToList(); return listAllCardGroups; } }
// GET: api/card public IEnumerable <Card> Get() { return(_rep.GetAll()); }