public async Task <IActionResult> PutUsuarios(int id, Usuarios usuarios) { if (id != usuarios.Id) { return(BadRequest()); } _context.Entry(usuarios).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UsuariosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutProyectos(int id, [FromForm] Proyectos proyectos, IFormFile imagen) { if (id != proyectos.IdProyecto) { return(BadRequest()); } if (imagen != null && imagen.Length > 0) { using (var ms = new MemoryStream()) { imagen.CopyTo(ms); var fileBytes = ms.ToArray(); string s = Convert.ToBase64String(fileBytes); // act on the Base64 data //proyectos.Imagen.SetValue(fileBytes); proyectos.ContentType = imagen.ContentType; proyectos.Imagen = fileBytes; } } _context.Entry(proyectos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProyectosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }