Esempio n. 1
0
        public async Task <IActionResult> PutTipsForEveryOne([FromRoute] Guid id, [FromBody] TipsForEveryOne tipsForEveryOne)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tipsForEveryOne.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> PostTipsForEveryOne([FromBody] TipsForEveryOne tipsForEveryOne)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.TipsForEveryOne.Add(tipsForEveryOne);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTipsForEveryOne", new { id = tipsForEveryOne.Id }, tipsForEveryOne));
        }