Exemple #1
0
        public async Task <IActionResult> PostEvent([FromBody] ContentService.Models.Profile @profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Profiles.Add(@profile);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (ProfileExists(@profile.ProfileId))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetProfile", new { id = @profile.ProfileId }, @profile));
        }
Exemple #2
0
        public async Task <IActionResult> PutProfile([FromRoute] int id, [FromBody] ContentService.Models.Profile @profile)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != @profile.ProfileId)
            {
                return(BadRequest());
            }

            _context.Entry(@profile).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProfileExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }