Esempio n. 1
0
        public void ParseListOfCardsToDictionaryByStatuses_TestWithListOfCardsIfInProgressStatusOnly()
        {
            //Arrange
            var cards = InitializeCardsWithInProgressStatusOnly();
            //Act
            var result = DataManipulationHelper.ParseListOfCardsToDictionaryByStatuses(cards);

            //Assert
            Assert.AreEqual(result.Keys.Count, 1);
            Assert.IsTrue(!result.ContainsKey(Status.NotStarted));
            Assert.IsTrue(result.ContainsKey(Status.InProgress));
            Assert.IsTrue(!result.ContainsKey(Status.Done));
        }
Esempio n. 2
0
        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"));
            }
        }