public Attendee Add(Attendee attendee)
 {
     // Adding the attendee object and returning it
     context.Attendees.Add(attendee);
     context.SaveChanges();
     return(attendee);
 }
 public Conference Add(Conference conference)
 {
     // Adding conference object and returning it
     context.Conferences.Add(conference);
     context.SaveChanges();
     return(conference);
 }
 public Organizer Add(Organizer organizer)
 {
     // Adding the organizer object and returning it
     context.Organizers.Add(organizer);
     context.SaveChanges();
     return(organizer);
 }
        public int Add(Conference entity)
        {
            _conferenceDbContext.Conferences.Add(entity);

            _conferenceDbContext.SaveChanges();

            return(entity.IdConference);
        }
        public int Add(Speaker entity)
        {
            _conferenceDbContext.Speakers.Add(entity);

            _conferenceDbContext.SaveChanges();

            return(entity.IdSpeaker);
        }
        public int Add(MyAgenda entity)
        {
            _conferenceDbContext.MyAgenda.Add(entity);

            _conferenceDbContext.SaveChanges();

            return(entity.IdMyAgenda);
        }
        public When_retrieving_sessions_from_the_database()
        {
            _mockConnectionOption = new Moq.Mock <IOptions <ConnectionOption> >();
            ConnectionOption connectionOption = new ConnectionOption
            {
                ConCode = ConCodeConfiguration.Config["ConnectionStrings:ConCode"]
            };

            _mockConnectionOption.SetupGet(x => x.Value).Returns(connectionOption);
            _conferenceDbContext = new ConferenceDbContext(_mockConnectionOption.Object);

            _testSpeaker = new User
            {
                FirstName   = "Luke",
                LastName    = "Skywalker",
                Username    = "******",
                ModifiedBy  = "unit test",
                SpeakerInfo = new SpeakerInfo
                {
                    Tagline = "You're not my father!",
                    Talks   = new List <Talk> {
                        new Talk {
                            Title = "How to find your father"
                        }
                    }
                }
            };
            _conferenceDbContext.Users.Add(_testSpeaker);
            _testTalkTypes = new List <TalkType>
            {
                new TalkType {
                    Name = "Standard", Length = TimeSpan.FromMinutes(75)
                },
                new TalkType {
                    Name = "Lightening", Length = TimeSpan.FromMinutes(15)
                },
            };
            _conferenceDbContext.SaveChanges();

            _testSession = new Session
            {
                Talk     = _testSpeaker.SpeakerInfo.Talks.First(),
                Start    = new DateTime(2016, 08, 20),
                Status   = SessionStatus.Full,
                TalkType = _testTalkTypes.Last()
            };
            _conferenceDbContext.Sessions.Add(_testSession);
            _conferenceDbContext.SaveChanges();
        }
        public void Should_delete_user()
        {
            var user = _conferenceDbContext.Users.FirstOrDefault(x => x.FirstName == "Luke");

            _conferenceDbContext.Users.Remove(user);
            _conferenceDbContext.SaveChanges();
            user = _conferenceDbContext.Users.FirstOrDefault(x => x.FirstName == "Luke");
            Assert.Null(user);
        }
        public void Dispose()
        {
            var session = _conferenceDbContext.Sessions.FirstOrDefault(x => x.Start == new DateTime(2016, 08, 20));

            if (session != null)
            {
                _conferenceDbContext.Sessions.Remove(session);
            }
            var user = _conferenceDbContext.Users.FirstOrDefault(x => x.FirstName == "Luke");

            if (user != null)
            {
                _conferenceDbContext.Users.Remove(user);
                _conferenceDbContext.SaveChanges();
            }
        }
        public When_retrieving_users_from_the_database()
        {
            _mockConnectionOption = new Moq.Mock <IOptions <ConnectionOption> >();
            ConnectionOption connectionOption = new ConnectionOption
            {
                ConCode = ConCodeConfiguration.Config["ConnectionStrings:ConCode"]
            };

            _mockConnectionOption.SetupGet(x => x.Value).Returns(connectionOption);
            _conferenceDbContext = new ConferenceDbContext(_mockConnectionOption.Object);

            _testUser = new User {
                FirstName   = "Luke",
                LastName    = "Skywalker",
                Username    = "******",
                ModifiedBy  = "unit test",
                SpeakerInfo = new SpeakerInfo {
                    Tagline = "You're not my father!"
                }
            };
            _conferenceDbContext.Users.Add(_testUser);
            _conferenceDbContext.SaveChanges();
        }
Esempio n. 11
0
        public static void Seed(this ConferenceDbContext dbContext)
        {
            dbContext.Database.EnsureCreated();
            if (!dbContext.Speakers.Any())
            {
                dbContext.Speakers.Add(new Speaker()
                {
                    CompanyName    = "Microsoft",
                    CompanyWebsite = "http://microsoft.com",
                    Email          = "*****@*****.**",
                    FirstName      = "Scott",
                    LastName       = "Hanselman",
                    Position       = "Program Manager",
                    Description    = "Speaker, Teacher, Coder, Blogger",
                    PageSlug       = "scott-hanselman",
                    GitHub         = "http:///github.com",
                    LinkedIn       = "http:///linkedin.com"
                });

                dbContext.Speakers.Add(new Speaker()
                {
                    CompanyName    = "Endava",
                    CompanyWebsite = "http://endava.com",
                    Email          = "*****@*****.**",
                    FirstName      = "Irina",
                    LastName       = "Scurtu",
                    Position       = "Design Lead",
                    Description    = "lalalaalala",
                    PageSlug       = "irina-scurtu",
                    GitHub         = "http:///github.com",
                    LinkedIn       = "http:///linkedin.com"
                });

                dbContext.Speakers.Add(new Speaker()
                {
                    CompanyName    = "Google",
                    CompanyWebsite = "http://google.com",
                    Email          = "*****@*****.**",
                    FirstName      = "Irina",
                    LastName       = "xyz",
                    Position       = "Devops",
                    Description    = "lalalaalala",
                    PageSlug       = "irina-xyz",
                    GitHub         = "http:///github.com",
                    LinkedIn       = "http:///linkedin.com"
                });
            }
            dbContext.SaveChanges();
            if (!dbContext.Talks.Any())
            {
                dbContext.Talks.Add(new Talk()
                {
                    Description = "There is an entire universe outside REST apis. You just need to fly there",
                    Title       = "GraphQL",
                    SpeakerId   = dbContext.Speakers.First().Id
                });

                dbContext.Talks.Add(new Talk()
                {
                    Description = "this could be a super nice talk, and it was. Super nice, Vital topic",
                    Title       = "Yet another graphql talk 2",
                    SpeakerId   = dbContext.Speakers.First().Id
                });
            }

            dbContext.SaveChanges();
        }