コード例 #1
0
        public async Task <ConferenceDetails> AddNewConferenceAsync(ConferenceDetails conference)
        {
            var conf = _mapper.Map <Model.Conference>(conference);

            _conferencesDbContext.Conferences.Add(conf);
            await _conferencesDbContext.SaveChangesAsync();

            return(_mapper.Map <Shared.DTO.ConferenceDetails>(conf));
        }
コード例 #2
0
        public async Task <ConferenceDetails> AddNewConferenceAsync(ConferenceDetails conference)
        {
            var conf = _mapper.Map <Model.Conference>(conference);

            conf.DateCreated = DateTime.UtcNow;

            _conferencesDbContext.Conferences.Add(conf);
            await _conferencesDbContext.SaveChangesAsync();

            await _hubContext.Clients.All.SendAsync("NewConferenceAdded");

            return(_mapper.Map <Shared.DTO.ConferenceDetails>(conf));
        }
コード例 #3
0
        public async Task <ActionResult <Shared.DTO.ConferenceDetails> > PostConference(Shared.DTO.ConferenceDetails conference)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var conf = _mapper.Map <Model.Conference>(conference);

            _conferencesDbContext.Conferences.Add(conf);

            await _conferencesDbContext.SaveChangesAsync();

            return(CreatedAtAction("Get", new { id = conference.ID }, _mapper.Map <Shared.DTO.ConferenceDetails>(conf)));
        }
コード例 #4
0
        public async Task <ActionResult <Shared.DTO.ConferenceDetails> > PostConference(Shared.DTO.ConferenceDetails conference)
        {
            if (!_validator.IsValidPeriod(conference.DateFrom, conference.DateTo))
            {
                return(BadRequest());
            }

            var conf = _mapper.Map <Conference>(conference);

            _conferencesDbContext.Conferences.Add(conf);
            await _conferencesDbContext.SaveChangesAsync();

            await _hubContext.Clients.All.SendAsync("NewConferenceAdded");

            return(CreatedAtAction("Get", new { id = conference.ID }, _mapper.Map <Shared.DTO.ConferenceDetails>(conf)));
        }
        public async Task <ActionResult <ConferenceDetails> > PostConference(ConferenceDetails conference)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var conf = _mapper.Map <Conference>(conference);

            _context.Conferences.Add(conf);
            await _context.SaveChangesAsync();

            await _hubContext.Clients.All.SendAsync("NewConferenceAdded");

            return(CreatedAtAction("GetConference", new { id = conference.ID }, conf));
        }
コード例 #6
0
        public async Task <ActionResult <Shared.DTO.ConferenceDetails> > PostConference(Shared.DTO.ConferenceDetails conference)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var conf = _mapper.Map <Model.Conference>(conference);

            conf.DateCreated = DateTime.UtcNow;

            _conferencesDbContext.Conferences.Add(conf);
            await _conferencesDbContext.SaveChangesAsync();

            await _hubContext.Clients.All.SendAsync("NewConferenceAdded");

            return(CreatedAtAction("Get", new { id = conference.ID }, _mapper.Map <Shared.DTO.ConferenceDetails>(conf)));
        }
コード例 #7
0
        public async Task AddAsync(Host host)
        {
            await _hosts.AddAsync(host);

            await _context.SaveChangesAsync();
        }
コード例 #8
0
 public async Task <int> CompleteAsync()
 {
     return(await _context.SaveChangesAsync());
 }
コード例 #9
0
        public async Task AddAsync(Conference conference)
        {
            await _conferences.AddAsync(conference);

            await _dbContext.SaveChangesAsync();
        }