Exemplo n.º 1
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());
        }
Exemplo n.º 2
0
 public virtual async Task AddAsync(T entity)
 {
     EntityEntry dbEntityEntry = _context.Entry <T>(entity);
     await _context.Set <T>().AddAsync(entity);
 }