async Task ExecuteLoadItemsCommand() { if (IsBusy) { return; } IsBusy = true; try { Items.Clear(); var lista = await eventsControllerObject.GetActivitiesList(); foreach (ActivitiesModel e in lista) { Items.Add(e); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
public void GetUserActivities(string GpUserId, string acces_token, Guid UserId) { ActivitiesController obj = new ActivitiesController(); GooglePlusActivitiesRepository objgpActRepo = new GooglePlusActivitiesRepository(); GooglePlusActivities objgpAct = new GooglePlusActivities(); JArray objActivity = obj.GetActivitiesList(GpUserId, acces_token); foreach (var itemActivity in objActivity) { foreach (var itemAct in itemActivity["items"]) { objgpAct.ActivityId = itemAct["id"].ToString(); objgpAct.ActivityUrl = itemAct["url"].ToString(); objgpAct.Content = itemAct["object"]["content"].ToString(); objgpAct.EntryDate = DateTime.Now; objgpAct.FromId = itemAct["actor"]["id"].ToString(); objgpAct.FromProfileImage = itemAct["actor"]["image"]["url"].ToString(); objgpAct.FromUserName = itemAct["actor"]["displayName"].ToString(); objgpAct.GpUserId = GpUserId; objgpAct.Id = Guid.NewGuid(); objgpAct.PlusonersCount = int.Parse(itemAct["object"]["plusoners"]["totalItems"].ToString()); objgpAct.RepliesCount = int.Parse(itemAct["object"]["replies"]["totalItems"].ToString()); objgpAct.ResharersCount = int.Parse(itemAct["object"]["resharers"]["totalItems"].ToString()); objgpAct.PublishedDate = itemAct["published"].ToString(); objgpAct.Title = itemActivity["title"].ToString(); objgpAct.UserId = UserId; if (!objgpActRepo.checkgoogleplusActivityExists(itemAct["id"].ToString(), UserId)) { objgpActRepo.addgoogleplusActivity(objgpAct); } else { objgpActRepo.updategoogleplusActivity(objgpAct); } } } }