Exemple #1
0
        public async Task <IActionResult> PosttblUserSessions([FromBody] tblUserSessions tblUserSessions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.tblUserSessions.Add(tblUserSessions);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (tblUserSessionsExists(tblUserSessions.UserID))
                {
                    return(new StatusCodeResult(StatusCodes.Status409Conflict));
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GettblUserSessions", new { id = tblUserSessions.UserID }, tblUserSessions));
        }
Exemple #2
0
        public async Task <IActionResult> PuttblUserSessions([FromRoute] int id, [FromBody] tblUserSessions tblUserSessions)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tblUserSessions.UserID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }