public void ShouldDelete()
        {
            SessionCard sessioncard = new SessionCard("new testimage", this.session.Id, "some more text");
            sessioncard = this.sessioncards.Create(sessioncard);

            this.sessioncards.Delete(sessioncard.Id);

            sessioncard = this.sessioncards.Read(sessioncard.Id);

            Assert.Null(sessioncard);
        }
        public void SetUp()
        {
            FakeContext context = new FakeContext();

            this.sessions = new SessionRepository(context);
            this.sessioncards = new SessionCardRepository(context);

            // all other objects than 'sessioncard' are available thanks to a migration test database seed
            this.session = this.sessions.Read(1);

            this.sessioncard = new SessionCard("testimage", this.session.Id, "some text");
            this.sessioncard = this.sessioncards.Create(sessioncard);
        }
        public void ShouldUpdate()
        {
            this.sessioncard = this.sessioncards.Read(this.sessioncard.Id);

            string image = "changedimage";
            string text = "changedtext";

            this.sessioncard.Image = image;
            this.sessioncard.Text = text;

            this.sessioncards.Update(sessioncard);
            this.sessioncard = this.sessioncards.Read(this.sessioncard.Id);

            Assert.AreEqual(this.sessioncard.Image, image);
            Assert.AreEqual(this.sessioncard.Text, text);
        }
        public IHttpActionResult PatchSelectCards(int id, [FromBody]ICollection<CardDto> dtos)
        {
            Session session = this.sessions.Get(id, collections: true);
            IEnumerable<SessionCard> sessionCards = this.sessionCards.Get(sc => sc.SessionId == id);

            foreach (CardDto dto in dtos) {
                SelectionCard slc = this.selectionCards.Get(dto.Id);

                if (!sessionCards.Any(sc => sc.Text == slc.Text)) {
                    SessionCard sc = new SessionCard(slc.Image, id, slc.Text);
                    session.SessionCards.Add(sc);
                    this.sessionCards.Add(sc);
                }
            }

            this.sessions.Change(session);

            return Ok();
        }