public bool EditarPersonal(PersonalDeLaEmpresaDTO editar_Personal) { if (editar_Personal != null) { _personal = _mapper.Map <PersonalDeLaEmpresa>(editar_Personal); // -------AQUÍ ESTOY ENCRIPTANDO LA CONTRASEÑA EN CASO DE HABER SIDO MODIFICADA. _personal.Pass = _protector.Protect(editar_Personal.Pass); // -------AQUÍ ESTOY ENCRIPTANDO LA CONTRASEÑA EN CASO DE HABER SIDO MODIFICADA. _personal.Estado = true; _dbcontext.Entry(_personal).State = EntityState.Modified; _dbcontext.SaveChanges(); return(true); } return(false); }
public ActionResult ActualizarDatosPersonalSoloEstado(int idPersonal, [FromBody] JsonPatchDocument <PersonalDeLaEmpresa> patchDocument) { //... var perfilDTO = _personal.PerfilDelPersonal(id_personal: idPersonal); if (patchDocument != null && perfilDTO != null) { var perfil = _mapper.Map <PersonalDeLaEmpresa>(perfilDTO); patchDocument.ApplyTo(perfil, ModelState); var isValid = TryValidateModel(perfil); if (!isValid) { return(BadRequest(ModelState)); } _context.SaveChanges(); return(Ok()); } return(BadRequest()); }