public static async Task <string> UserId() { var isLoggedIn = Settings.GetSetting(Settings.AppPrefrences.IsLoggedIn); if (isLoggedIn == null || isLoggedIn == "False") { DialogsHelper.HandleDialogMessage(DialogsHelper.Errors.Defined, "You're not logged in. Log in to perform this action."); } else { string userJson = await Settings.GetSecureSetting(Settings.AppPrefrences.User); var userObject = JsonConvert.DeserializeObject <User>(userJson); return(userObject.UserID); } return(null); }
public static async Task SaveArticle(Article article) { try { string userId = await UserId(); if (userId != null) { DialogsHelper.HandleDialogMessage(DialogsHelper.Errors.Defined, "Article Saved."); article.ID = ArticleId(article.Url); article.SavedOn = DateHelper.DateTimeHelper.ReturnCurrentTimeInLong(); await CrossCloudFirestore.Current.Instance .GetDocument($"articles/{userId}/saved-articles/{article.ID}") .SetDataAsync(article); } } catch (Exception ex) { Debug.WriteLine(ex.Message); } }