public async Task <bool> UpdateAsync(PersonalDTO model, string id) { try { var user = _databaseContext.Usuario .Include(u => u.Rol) .Single(u => u.Id == id); if (model.Email != null) { user.Email = model.Email; user.UserName = model.Email; } if (model.NombrePersonal != null) { user.NombrePersonal = model.NombrePersonal; } if (model.ApellidoPersonal != null) { user.ApellidoPersonal = model.ApellidoPersonal; } if (model.Cargo != null) { user.Cargo = model.Cargo; } if (model.PhoneNumber != null) { user.PhoneNumber = model.PhoneNumber; } if (model.Pais != null) { user.Pais = model.Pais; } if (model.newPassword != null) { var token = await _userManager.GeneratePasswordResetTokenAsync(user); await _userManager.ResetPasswordAsync(user, token, model.newPassword); } await _userManager.UpdateAsync(user); await _databaseContext.SaveChangesAsync(); return(true); } catch (Exception e) { Console.WriteLine(e); return(false); } }
private async Task ChangeUserPassword(string email, string password) { try { var user = _simepadf.Usuario.Single(u => u.Email == email); var token = await _userManager.GeneratePasswordResetTokenAsync(user); await _userManager.ResetPasswordAsync(user, token, password); await _userManager.UpdateAsync(user); await _simepadf.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); throw; } }
private void UpdateProjectPercent(string idProyect) { try { var project = _context.Proyecto.Single(p => p.CodigoProyecto == idProyect); var accumulated = 0.0; foreach (var reg in _context.PlanSocioDesagregacion.Where(psd => psd.PlanDesagregacionPlanMonitoreoEvaluacionProyectoCodigoProyecto == idProyect)) { accumulated += reg.Valor; } project.PorcentajeAvence = accumulated; _context.SaveChangesAsync(); } catch (Exception e) { Console.WriteLine(e); throw; } }