Пример #1
0
        public async Task <IActionResult> PutRole(int id, Role role)
        {
            if (id != role.RoleId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <int> UpdateByUserIdRepository(User user)
        {
            int result = 0;

            try
            {
                if (UserExists(user.UserId))
                {
                    _context.Entry(user).State = EntityState.Modified;
                    result = await _context.SaveChangesAsync();
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }