예제 #1
0
        public async Task UpdateSessionAsync(SessionDetailModel Session, List <SpeakerHasSessionModel> Speakers)
        {
            var entity = await DbContext.Session.FirstOrDefaultAsync(s => s.IdSession == Session.IdSession);

            entity.Name           = Session.Name;
            entity.StartDate      = Session.StartDate;
            entity.EndDate        = Session.EndDate;
            entity.Description    = Session.Description;
            entity.IconLink       = Session.IconLink;
            entity.IdSessionLevel = Session.IdSessionLevel;
            entity.IdSessionType  = Session.IdSessionType;

            await DbContext.SaveChangesAsync();

            var entitySpeakerHasSession = new SpeakerHasSession()
            {
                IdSession = Session.IdSession
            };
        }
예제 #2
0
        public async Task DeleteSpeakerAsync(int IdSpeaker)
        {
            var entitySpeakerHasSession = new SpeakerHasSession()
            {
                IdSpeaker = IdSpeaker
            };

            DbContext.SpeakerHasSession.Attach(entitySpeakerHasSession);
            DbContext.SpeakerHasSession.Remove(entitySpeakerHasSession);
            await DbContext.SaveChangesAsync();

            var entity = new Speaker()
            {
                IdSpeaker = IdSpeaker
            };

            DbContext.Speaker.Attach(entity);
            DbContext.Speaker.Remove(entity);
            await DbContext.SaveChangesAsync();
        }
예제 #3
0
        public async Task InsertSessionAsync(SessionDetailModel Session, List <SpeakerListModel> Speakers)
        {
            var entity = new Session()
            {
                Name           = Session.Name,
                StartDate      = Session.StartDate,
                EndDate        = Session.EndDate,
                Description    = Session.Description,
                IconLink       = Session.IconLink,
                IdSessionLevel = Session.IdSessionLevel,
                IdSessionType  = Session.IdSessionType
            };

            DbContext.Session.Add(entity);
            await DbContext.SaveChangesAsync();

            await DbContext.Entry(entity).GetDatabaseValuesAsync();

            int IdS = entity.IdSession;

            Console.WriteLine("-------------------------");
            Console.WriteLine(IdS);

            foreach (var s in Speakers)
            {
                var speakatsession = new SpeakerHasSession()
                {
                    IdSpeaker = s.IdSpeaker,
                    IdSession = IdS
                };

                Console.WriteLine(speakatsession.IdSession + " - " + speakatsession.IdSpeaker);

                await DbContext.SpeakerHasSession.AddAsync(speakatsession);

                await DbContext.SaveChangesAsync();
            }
        }