/// <summary> /// Actualiza un usuario por id en la base de datos /// </summary> /// <param name="user">usuario a modificar</param> /// <param name="session">sesion del usuario</param> /// <returns>UserApp</returns> public async Task <UserApp> UserAppUpdate(UserApp user, UserSession session) { try { if (await _userAppData.ExistUserByUserName(user)) { var control = await _controlsLanguageData.ControlFindByKey("UserExistForName", 2, session.LanguageId); throw control.CreateException(user.UserName); } var oldUser = await _userAppData.GetAsync(user.UserId); oldUser.UpdateDate = DateTime.Now; oldUser.UserUpdateId = session.Id; oldUser.UserDocument = user.UserDocument; oldUser.UserDocumentTypeId = user.UserDocumentTypeId; oldUser.UserEmail = user.UserEmail; oldUser.UserFirstName = user.UserFirstName; oldUser.UserLastName = user.UserLastName; await _userAppData.UpdateAsync(oldUser); return(oldUser); } catch (Exception) { throw; } }