Example #1
0
        public async Task <IActionResult> PutBirthday(int id, Birthday birthday)
        {
            if (id != birthday.Id)
            {
                return(BadRequest());
            }

            _context.Entry(birthday).State = EntityState.Modified;

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

            return(NoContent());
        }
        public async Task <IActionResult> Post([FromBody] Birthday value)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            context.Birthdays.Add(value);
            await context.SaveChangesAsync();

            return(Ok());
        }