private void InitializeInstaAPI(IInstagramAPI instaApi)
        {
            _instaApi = instaApi;

            if (System.Web.HttpContext.Current.Session["PrimaryKey"] != null)
            {
                string currentUserPrimaryKey = System.Web.HttpContext.Current.Session["PrimaryKey"].ToString();

                if (!string.IsNullOrEmpty(currentUserPrimaryKey))
                {
                    _instaApi.SetCookies(GetInstagramCookiesByUserPrimaryKey(currentUserPrimaryKey));
                }
            }
        }
Beispiel #2
0
        private async Task <List <InstagramPost> > GetProfileStateAsync(IInstagramAPI instagramAPI, User profileOwner)
        {
            List <InstagramPost> posts = null;

            var profile = await _repository.GetAsync <UserProfile>(p => p.Owner.Equals(profileOwner));

            if (profile != null) // Profile state already exists in DB.
            {
                posts = profile.Posts;
            }
            else // We have to parse it from Instagram.
            {
                posts = instagramAPI.GetUserPostsByPrimaryKey(profileOwner.InstagramPK);
            }

            return(posts);
        }
 public HomeController(IRepository repository, IInstagramAPI instaApi)
 {
     _repository = repository;
     InitializeInstaAPI(instaApi);
 }
Beispiel #4
0
 public AccountController(IRepository repo, IInstagramAPI instagramAPI)
 {
     _repository = repo;
     InitializeInstaAPI(instagramAPI);
 }