Esempio n. 1
0
        public void GetById()
        {
            RepositoryDataAccessInstagram _repo = new RepositoryDataAccessInstagram();
            var result = _repo.GetByCode("5a078ad0-d051-4ba3-92ad-d5f9f55ea44c");

            Assert.IsNotNull(result);
        }
Esempio n. 2
0
        public void GetIsValid()
        {
            RepositoryDataAccessInstagram _repo = new RepositoryDataAccessInstagram();
            var result = _repo.GetIsValid();

            Assert.IsNotNull(result);
        }
Esempio n. 3
0
        public async Task <ActionResult> OAuth(string code)
        {
            // add this code to the auth object
            var auth = new OAuth();

            // now we have to call back to instagram and include the code they gave us
            // along with our client secret
            var oauthResponse = await auth.RequestToken(code);

            oauthResponse = await auth.RequestToken(code);

            if (oauthResponse != null)
            {
                var data = oauthResponse.Map <OAuthResponse, DataAccessInstagram>();
                RepositoryDataAccessInstagram repo = new RepositoryDataAccessInstagram();

                if (data != null)
                {
                    repo.Save(data);
                }
            }

            // all done, lets redirect to the home controller which will send some intial data to the app
            return(View(oauthResponse.User));
        }
        public async Task <IHttpActionResult> GetMidiasByGeoLocation(Double numLati, Double numLong, String desLocal)
        {
            try
            {
                RepositoryDataAccessInstagram repo = new RepositoryDataAccessInstagram();
                var auth = new OAuth();

                OAuthResponse oauthResponse;

                var dataAccess = repo.GetIsValid();

                if (dataAccess != null)
                {
                    oauthResponse = dataAccess.Map <DataAccessInstagram, OAuthResponse>();
                }
                else
                {
                    LogonInstagram logon = new LogonInstagram();
                    var            token = await logon.GetToken();

                    oauthResponse = await auth.RequestToken(token);

                    if (oauthResponse != null)
                    {
                        var data = oauthResponse.Map <OAuthResponse, DataAccessInstagram>();

                        if (data != null)
                        {
                            repo.Save(data);
                        }
                    }
                }

                var midia  = new Hackathon.Instagram.Core.EndPoint.Media(auth.Config, oauthResponse);
                var result = await midia.Search(numLati, numLong);

                if (String.IsNullOrEmpty(desLocal))
                {
                    return(Ok(result.Data));
                }
                else
                {
                    var data = result.Data.Where(x => x.Location != null && x.Location.Name.Contains(desLocal)).ToList();
                    return(Ok(data));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest("An has ocorred : " + ex.Message));
            }
        }
        public async Task <IHttpActionResult> GetVideoByGeoLocation(Double numLati, Double numLong, String desLocal)
        {
            try
            {
                RepositoryDataAccessInstagram repo = new RepositoryDataAccessInstagram();
                var auth = new OAuth();

                OAuthResponse oauthResponse;

                var dataAccess = repo.GetIsValid();

                if (dataAccess != null)
                {
                    oauthResponse = dataAccess.Map <DataAccessInstagram, OAuthResponse>();
                }
                else
                {
                    LogonInstagram logon = new LogonInstagram();
                    var            token = await logon.GetToken();

                    oauthResponse = await auth.RequestToken(token);

                    if (oauthResponse != null)
                    {
                        var data = oauthResponse.Map <OAuthResponse, DataAccessInstagram>();

                        if (data != null)
                        {
                            repo.Save(data);
                        }
                    }
                }

                var midia  = new Hackathon.Instagram.Core.EndPoint.Media(auth.Config, oauthResponse);
                var result = await midia.Search(numLati, numLong);

                var videos = this.GetOnlyVideos(result.Data, desLocal);

                return(Ok(videos));
            }
            catch (Exception ex)
            {
                return(BadRequest("An has ocorred : " + ex.Message));
            }
        }
Esempio n. 6
0
        public void Save()
        {
            DataAccessInstagram data = new DataAccessInstagram();

            data.AccessToken      = Guid.NewGuid().ToString();
            data.RegistrationDate = DateTime.Now;
            data.Id             = Guid.NewGuid();
            data.FullName       = "Pomposo Filho";
            data.DueDate        = null;
            data.IsValid        = true;
            data.ProfilePicture = "http://www.bloblo.com.br";
            data.UserName       = "******";

            RepositoryDataAccessInstagram _repo = new RepositoryDataAccessInstagram();

            var result = _repo.Save(data);

            Assert.IsTrue(result);
        }
Esempio n. 7
0
        public async Task <ActionResult> Index()
        {
            RepositoryDataAccessInstagram repo = new RepositoryDataAccessInstagram();
            var           auth = new OAuth();
            OAuthResponse oauthResponse;

            var dataAccess = repo.GetIsValid();

            if (dataAccess != null)
            {
                oauthResponse = dataAccess.Map <DataAccessInstagram, OAuthResponse>();
            }
            else
            {
                LogonInstagram logon = new LogonInstagram();
                var            token = await logon.GetToken();

                oauthResponse = await auth.RequestToken(token);

                if (oauthResponse != null)
                {
                    var data = oauthResponse.Map <OAuthResponse, DataAccessInstagram>();

                    if (data != null)
                    {
                        repo.Save(data);
                    }
                }
            }

            if (oauthResponse == null)
            {
                return(Redirect(auth.AuthLink()));
            }
            else
            {
                return(View(oauthResponse.User));
            }
        }