public RequestsHistoryViewModel() { // Set this property when initialized, to show current user requests on form // using mvvm approach and list box try { UserTextRequests = WordsCountServiceWrapper.GetTextRequests(StationManager.CurrentUser.Id); } catch (Exception e) { Logger.Log($"Error getting user {StationManager.CurrentUser} text requests", e); } }
public MainWindow() { // deserializing user when app starts // if such users exists do autologin else redirect to login var user = SerializeManager.Deserialize <User>(StationManager.UserFilePath); var userNameIsEmpty = String.IsNullOrEmpty(user?.UserName); // In case the previous function returned new User() if (!userNameIsEmpty) { try { StationManager.CurrentUser = WordsCountServiceWrapper.GetUserByName(user.UserName); } catch (Exception e) { Logger.Log("Error getting user", e); } if (StationManager.CurrentUser != null) { // writing logs (what current user have just done) Logger.Log($"User {StationManager.CurrentUser?.UserName} was autologged-in"); try { StationManager.CurrentUser.LastVisit = DateTime.Now; WordsCountServiceWrapper.EditEntity(StationManager.CurrentUser); } catch (Exception e) { Logger.Log("Error updating user", e); } GoToCabinet(); return; } Logger.Log("Error on autologin"); } Login(); }