Esempio n. 1
0
        public async Task <IActionResult> PutSessionRec([FromRoute] int id, [FromBody] SessionRec sessionRec)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutSessionRec([FromRoute] int id, [FromBody] SessionRec sessionRec)
        {
            await Task.Delay(1000); // force the UI to show the saving message (not production necessary)

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

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

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

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

            //return NoContent();
            return(Ok(sessionRec));
        }
Esempio n. 3
0
        public async Task <IActionResult> PostSessionRec([FromBody] SessionRec sessionRec)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.SessionRecs.Add(sessionRec);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetSessionRec", new { id = sessionRec.Id }, sessionRec));
        }