public TimelogViewModel GetTimelogViewModel(ITimelogUsingView view) { if (timelogViewModel != null) { timelogViewModel.TimelogUsingView = view; return(timelogViewModel); } var timelogSettingObj = from TimelogSetting tlSetting in dellAppDB.TimelogSetting select tlSetting; if (timelogSettingObj.Count() > 0) { timelogViewModel = new TimelogViewModel(timelogSettingObj.Single(), view); } else { TimelogSetting newTlSetting = new TimelogSetting() { TimelogSettingID = System.Guid.NewGuid().ToString(), TimelogUrl = "https://" }; dellAppDB.TimelogSetting.InsertOnSubmit(newTlSetting); dellAppDB.SubmitChanges(); timelogViewModel = new TimelogViewModel(newTlSetting, view); } return(timelogViewModel); }
public TimelogViewModel(TimelogSetting tlSetting, ITimelogUsingView view) { timelogSetting = tlSetting; timelogUsingView = view; username = tlSetting.Username; isLoginBackground = tlSetting.LoginBackground; if (!String.IsNullOrEmpty(username)) { isSaveCredentials = true; } else { isSaveCredentials = false; } url = tlSetting.TimelogUrl; #if DEBUG url = ""; #endif if (!String.IsNullOrEmpty(tlSetting.Password)) { try { password = HelperClass.GetDecryptedPWString(tlSetting.Password); } catch { password = ""; timelogUsingView.ShowErrorMessage("Please retype your login credentials. Password couldn't be restored because of different device."); } } lastSynchronisationTimestamp = tlSetting.LastSynchronisationTimestamp; TlTaskCollection = App.AppViewModel.GetTimelogTasks(); TlWorktaskCollection = App.AppViewModel.GetAllWorktasksForTimelog(); }