示例#1
0
        public async Task <IActionResult> CreateConference([FromBody] ConferenceDTO.Conference input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var conference = new Conference
            {
                Name = input.Name
            };

            _db.Conferences.Add(conference);
            await _db.SaveChangesAsync();

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID   = conference.ID,
                Name = conference.Name,
                //Sessions = ??,
                //Tracks = ??
                //Sessions = ??
            };

            return(CreatedAtAction(nameof(GetConference), new { id = conference.ID }, result));
        }
示例#2
0
        public async Task <IActionResult> UpdateConference([FromRoute] int id, [FromBody] ConferenceDTO.Conference input)
        {
            var conference = await _db.FindAsync <Conference>(id);

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

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            conference.Name = input.Name;

            await _db.SaveChangesAsync();

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID   = conference.ID,
                Name = conference.Name,
                //Sessions = ??,
                //Tracks = ??
                //Sessions = ??
            };

            return(Ok(result));
        }
        public async Task <IActionResult> GetConferenceBySlug([FromRoute] string id)
        {
            var c = await _db.Conferences
                    .Include(x => x.ConferenceOrganisers)
                    .FirstOrDefaultAsync(x => x.Slug.Equals(id, StringComparison.InvariantCultureIgnoreCase));

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

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID                   = c.ID,
                Name                 = c.Name,
                Slug                 = c.Slug,
                StartDate            = c.StartDate,
                Description          = c.Description,
                EndDate              = c.EndDate,
                Address1             = c.Address1,
                Address2             = c.Address2,
                City                 = c.City,
                ConferenceOrganisers = c.ConferenceOrganisers,
                Country              = c.Country,
                Latitude             = c.Latitude,
                Longitude            = c.Longitude,
                PostCode             = c.PostCode,
            };

            return(Ok(result));
        }
        public async Task <IActionResult> GetConference([FromRoute] string id)
        {
            var c = await _db.FindAsync <Conference>(id);

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

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID                   = c.ID,
                Name                 = c.Name,
                StartDate            = c.StartDate,
                Description          = c.Description,
                EndDate              = c.EndDate,
                Address1             = c.Address1,
                Address2             = c.Address2,
                City                 = c.City,
                ConferenceOrganisers = c.ConferenceOrganisers,
                Country              = c.Country,
                Latitude             = c.Latitude,
                Longitude            = c.Longitude,
                PostCode             = c.PostCode,
            };

            return(Ok(result));
        }
        public async Task <IActionResult> CreateConference([FromBody] ConferenceDTO.Conference input)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var c = new Conference
            {
                Name        = input.Name,
                StartDate   = input.StartDate,
                Description = input.Description,
                EndDate     = input.EndDate,
                Address1    = input.Address1,
                Address2    = input.Address2,
                City        = input.City,
                Country     = input.Country,
                Latitude    = input.Latitude,
                Longitude   = input.Longitude,
                PostCode    = input.PostCode,
            };

            _db.Conferences.Add(c);
            await _db.SaveChangesAsync();

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID                   = c.ID,
                Name                 = c.Name,
                StartDate            = c.StartDate,
                Description          = c.Description,
                EndDate              = c.EndDate,
                Address1             = c.Address1,
                Address2             = c.Address2,
                City                 = c.City,
                ConferenceOrganisers = c.ConferenceOrganisers,
                Country              = c.Country,
                Latitude             = c.Latitude,
                Longitude            = c.Longitude,
                PostCode             = c.PostCode,
            };

            return(CreatedAtAction(nameof(GetConference), new { id = c.ID }, result));
        }
示例#6
0
        public async Task <IActionResult> GetConference([FromRoute] int id)
        {
            var conference = await _db.FindAsync <Conference>(id);

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

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID   = conference.ID,
                Name = conference.Name,
                //Sessions = ??,
                //Tracks = ??
                //Sessions = ??
            };

            return(Ok(result));
        }
        public async Task <IActionResult> UpdateConference([FromRoute] Guid id, [FromBody] ConferenceDTO.Conference input)
        {
            var c = await _db.FindAsync <Conference>(id);

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

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            c.Name = input.Name;

            await _db.SaveChangesAsync();

            var result = new ConferenceDTO.ConferenceResponse
            {
                ID                   = c.ID,
                Name                 = c.Name,
                StartDate            = c.StartDate,
                Description          = c.Description,
                EndDate              = c.EndDate,
                Address1             = c.Address1,
                Address2             = c.Address2,
                City                 = c.City,
                ConferenceOrganisers = c.ConferenceOrganisers,
                Country              = c.Country,
                Latitude             = c.Latitude,
                Longitude            = c.Longitude,
                PostCode             = c.PostCode,
            };

            return(Ok(result));
        }