public async Task <PermisoRole> save(PermisoRole model) { await _context.PermisoRole.AddAsync(model); await _context.SaveChangesAsync(); return(model); }
public async Task <ActionResult> Post([FromBody] PermisoRole model) { if (!ModelState.IsValid) { return(BadRequest()); } await _permisoRole.save(model); return(Ok(model)); }
public async Task <PermisoRole> Edit(PermisoRole model) { try { _context.Entry(model).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(model); }
public async Task <ActionResult> Put(int id, [FromBody] PermisoRole model) { if (id != model.IdPermiso) { return(BadRequest()); } try { await _permisoRole.Edit(model); } catch (Exception ex) { if (Exists(id)) { return(BadRequest()); } throw ex; } return(Ok(model)); }