Beispiel #1
0
        public async Task <IActionResult> DeleteClub([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var club = await repo.GetClub(id);

            if (!await repo.ClubExists(id))
            {
                return(NotFound());
            }

            repo.Delete(club);
            await repo.SaveAllChangesAsync();

            return(Ok(club));
        }
Beispiel #2
0
        public async Task <IActionResult> DeleteMember([FromRoute] int id)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var member = await repo.GetMember(id);

            if (member == null)
            {
                return(NotFound());
            }

            repo.Delete(member);

            await repo.SaveAllChangesAsync();

            logger.LogInformation("Deleted member", member);
            return(Ok(member));
        }
Beispiel #3
0
        public void MembershipRepository()
        {
            Mock <IDbSetFactory>       factory = new Mock <IDbSetFactory>();
            Mock <DbSet <Membership> > dbSet   = new Mock <DbSet <Membership> >();

            factory.Setup(m => m.CreateDbSet <Membership>()).Returns(dbSet.Object);

            MembershipRepository repo = new MembershipRepository(factory.Object);

            var Membership = new Membership();

            var sequence = new MockSequence();

            dbSet.InSequence(sequence).Setup(e => e.Add(Membership));
            dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id));
            repo.Create(Membership);
            repo.Get(Membership.Id);
            repo.Update(Membership);
            repo.Delete(Membership.Id);
        }
        public void MembershipRepository()
        {
            Mock<IDbSetFactory> factory = new Mock<IDbSetFactory>();
            Mock<DbSet<Membership>> dbSet = new Mock<DbSet<Membership>>();

            factory.Setup(m => m.CreateDbSet<Membership>()).Returns(dbSet.Object);

            MembershipRepository repo = new MembershipRepository(factory.Object);

            var Membership = new Membership();

            var sequence = new MockSequence();
            dbSet.InSequence(sequence).Setup(e => e.Add(Membership));
            dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id));
            dbSet.InSequence(sequence).Setup(e => e.Find(Membership.Id));
            repo.Create(Membership);
            repo.Get(Membership.Id);
            repo.Update(Membership);
            repo.Delete(Membership.Id);
        }