public async Task <IActionResult> Post([FromBody] Aspnetroles role)
        {
            //_context.Aspnetroles.Add(role);
            await _roleManager.CreateAsync(role);

            //await _context.SaveChangesAsync();
            return(Ok(role));
        }
        public async Task <IActionResult> PutRole([FromRoute] string id, [FromBody]  Aspnetroles newrole)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            var role = _roleManager.FindByIdAsync(id).Result;

            if (role == null)
            {
                return(BadRequest("Ruolo non esiste!"));
            }

            if (role.Name != newrole.Name)
            {
                role.Name = newrole.Name;
            }

            try
            {
                await _roleManager.UpdateAsync(role);
            }

            catch
            {
                throw;
            }

            return(NoContent());
        }
예제 #3
0
 void IRoleService.Inserir(Aspnetroles aspnetroles)
 {
     throw new System.NotImplementedException();
 }
예제 #4
0
 string IRoleService.Editar(Aspnetroles aspnetroles)
 {
     throw new System.NotImplementedException();
 }
예제 #5
0
 public void Editar(Aspnetroles aspnetroles)
 {
     _context.Update(aspnetroles);
     _context.SaveChanges();
 }
예제 #6
0
 public string Inserir(Aspnetroles aspnetroles)
 {
     _context.Add(aspnetroles);
     _context.SaveChanges();
     return(aspnetroles.Id);
 }