// GET api/users/{$id}?token={$token}/
        // FEATURE: Visualizar perfil
        public HttpResponseMessage Get(string id, [FromUri] string token)
        {
            if (Authentication.VerifyToken(token))
            {
                try
                {
                    var queryResult = UserIntegration.View(HttpUtility.UrlDecode(id));

                    if (queryResult == null)
                    {
                        return(Request.CreateResponse(HttpStatusCode.NotFound));
                    }
                    else
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK, queryResult));
                    }
                }
                catch (Exception ex)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
                }
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.Forbidden));
            }
        }
Beispiel #2
0
        public void Delete(UserIntegration entity)
        {
            var userIntegration = _fakeUserIntegrations.FirstOrDefault(p => p.UserID == entity.UserID &&
                                                                       p.IntegrationTypeID == entity.IntegrationTypeID);

            _fakeUserIntegrations.Remove(userIntegration);
        }
Beispiel #3
0
        public void Update(UserIntegration entity)
        {
            DbEntityEntry dbEntityEntry = DbContext.Entry(entity);

            if (dbEntityEntry.State == EntityState.Detached)
            {
                DbSet.Attach(entity);
            }
            dbEntityEntry.State = EntityState.Modified;
        }
Beispiel #4
0
        private async Task UpdateStreamUrl(UserIntegration userIntegration)
        {
            var streamChannel = await _twitchClient.GetChannel(userIntegration.Token);

            if (streamChannel != null && userIntegration.UserName != streamChannel.name)
            {
                userIntegration.UserName = streamChannel.name;
                _unitOfWork.UserIntegrations.Update(userIntegration);
                _unitOfWork.Commit();
            }
        }
Beispiel #5
0
 public string GeneratePassword()
 {
     try
     {
         return(UserIntegration.GeneratePassword());
     }
     catch (Exception ex)
     {
         throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex));
     }
 }
Beispiel #6
0
 public int DeleteUser(int UserID)
 {
     try
     {
         return(UserIntegration.DeleteUser(UserID));
     }
     catch (Exception ex)
     {
         throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex));
     }
 }
 // GET api/users/
 // FEATURE: Listar vendedores
 public HttpResponseMessage Get()
 {
     try
     {
         return(Request.CreateResponse(HttpStatusCode.OK, UserIntegration.List()));
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Beispiel #8
0
 public User GetUserByLoginName(string loginName)
 {
     //User TheUser = null;
     //string UniqueKey = string.Concat("loginName_", loginName);
     //if (HttpRuntime.Cache[UniqueKey] == null)
     //{
     //    TheUser = UserIntegration.GetUserByLoginName(loginName);
     //    HttpRuntime.Cache[UniqueKey] = TheUser;
     //}
     //return ((User)(HttpRuntime.Cache[UniqueKey]));
     return(UserIntegration.GetUserByLoginName(loginName));
 }
Beispiel #9
0
        public void Add(UserIntegration entity)
        {
            DbEntityEntry dbEntityEntry = DbContext.Entry(entity);

            if (dbEntityEntry.State != EntityState.Detached)
            {
                dbEntityEntry.State = EntityState.Added;
            }
            else
            {
                DbSet.Add(entity);
            }
        }
Beispiel #10
0
        public void Delete(UserIntegration entity)
        {
            DbEntityEntry dbEntityEntry = DbContext.Entry(entity);

            if (dbEntityEntry.State != EntityState.Deleted)
            {
                dbEntityEntry.State = EntityState.Deleted;
            }
            else
            {
                DbSet.Attach(entity);
                DbSet.Remove(entity);
            }
        }
Beispiel #11
0
        public void GetById_CorrectDataGot_ActualEqualsExpectedData()
        {
            var expectedUserInegration = new UserIntegration
            {
                UserID            = 3,
                IntegrationTypeID = 1,
                Token             = "lkjlkjlk;jlkjlk3jlkjlkj"
            };
            UserIntegration actualUserIntegration;

            using (var userInegrationRepo = new UserIntegrationRepository(new brothershipEntities(ConnectionStrings.TEST_CONNECTION_STRING_NAME)))
            {
                actualUserIntegration = userInegrationRepo.GetById(expectedUserInegration.UserID, expectedUserInegration.IntegrationTypeID);
            }

            AssertUserInegrationsEqual(expectedUserInegration, actualUserIntegration);
        }
Beispiel #12
0
        private UserIntegration AddandGetTestUserIntegration()
        {
            var userIntegration = new UserIntegration
            {
                UserID            = 4,
                IntegrationTypeID = 1,
                Token             = "asdfwewrewreaw34"
            };

            using (var userIntegrationRepo = new UserIntegrationRepository(new brothershipEntities(ConnectionStrings.TEST_CONNECTION_STRING_NAME)))
            {
                userIntegrationRepo.Add(userIntegration);
                userIntegrationRepo.SaveChanges();
            }

            return(userIntegration);
        }
 // POST api/users/
 // FEATURE: Registar vendedor
 public HttpResponseMessage Post([FromBody] UserInfo jsonObject)
 {
     try
     {
         if (UserIntegration.Insert(jsonObject))
         {
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
         else
         {
             return(Request.CreateResponse(HttpStatusCode.NotFound));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
     }
 }
Beispiel #14
0
        public void Update_WasUserIntegrationUpdated_ActualEqualsExpectedData()
        {
            var expectedUserIntegration = new UserIntegration
            {
                UserID            = 3,
                IntegrationTypeID = 1,
                Token             = "asdlkfjsdlafjldasjf"
            };
            UserIntegration actualUserIntegration;

            using (var userIntegrationRepo = new UserIntegrationRepository(new brothershipEntities(ConnectionStrings.TEST_CONNECTION_STRING_NAME)))
            {
                userIntegrationRepo.Update(expectedUserIntegration);
                userIntegrationRepo.SaveChanges();
                actualUserIntegration = userIntegrationRepo.GetById(expectedUserIntegration.UserID, expectedUserIntegration.IntegrationTypeID);
            }

            AssertUserInegrationsEqual(expectedUserIntegration, actualUserIntegration);
        }
        public ActionResult oauthredirect(string state, string code)
        {
            var user = db.YellowAntUserStatesContext.Where(a => a.UserState == state).FirstOrDefault();

            if (user.UserUniqueID != User.Identity.GetUserId())
            {
                return(Redirect("http://f0008a02.ngrok.io/userintegration/integrate/"));
            }

            Yellowant ya = new Yellowant
            {
                AppKey      = "FvbTB2WePePZH3Zz7IEEvzPpe84FSosINSG67bus",
                AppSecret   = "6YMYY9oB9sU8imWBcYM3Z0MCjbnhCBCWbGHDICODyTLPmKXlqCeanEZrL9xNSuhZ9Eja54Mye5OfAPS2ZrJF1trT0Ag2byh31bMGXpFMQsvc2w5loBLuhmpK5q1d8HeT",
                RedirectURI = "http://f0008a02.ngrok.io/userintegration/oauthredirect",
                AccessToken = ""
            };
            dynamic AccessToken = ya.GetAccessToken(code);

            string    token = AccessToken.access_token;
            Yellowant yan   = new Yellowant
            {
                AccessToken = token
            };

            dynamic         user_integration = yan.CreateUserIntegration();
            dynamic         user_profile     = yan.GetUserProfile();
            UserIntegration integration      = new UserIntegration
            {
                YellowantUserID           = user.UserUniqueID,
                IntegrationID             = user_integration["user_application"],
                InvokeName                = user_integration["user_invoke_name"],
                YellowantIntegrationToken = token,
                YellowantTeamSubdomain    = "temp"
            };

            db.UserIntegrationContext.Add(integration);
            db.SaveChanges();
            return(Redirect("http://f0008a02.ngrok.io/userintegration/integrate/"));
        }
Beispiel #16
0
        public ActionResult oauthredirect(string state, string code)
        {
            var user = db.YellowAntUserStatesContext.Where(a => a.UserState == state).FirstOrDefault();

            if (user.UserUniqueID != User.Identity.GetUserId())
            {
                return(Redirect(redirecturl + "/userintegration/integrate/"));
            }

            Yellowant ya = new Yellowant
            {
                AppKey      = clientID,
                AppSecret   = clientSecret,
                RedirectURI = redirecturl + "/userintegration/oauthredirect",
                AccessToken = ""
            };
            dynamic AccessToken = ya.GetAccessToken(code);

            string    token = AccessToken.access_token;
            Yellowant yan   = new Yellowant
            {
                AccessToken = token
            };

            dynamic         user_integration = yan.CreateUserIntegration();
            dynamic         user_profile     = yan.GetUserProfile();
            UserIntegration integration      = new UserIntegration
            {
                YellowantUserID           = user.UserUniqueID,
                IntegrationID             = user_integration["user_application"],
                InvokeName                = user_integration["user_invoke_name"],
                YellowantIntegrationToken = token,
                YellowantTeamSubdomain    = "temp"
            };

            db.UserIntegrationContext.Add(integration);
            db.SaveChanges();
            return(Redirect(redirecturl + "/userintegration/integrate/"));
        }
        public ActionResult oauthredirect(string state, string code)
        {
            var user = db.YellowantUserStatesContext.Where(a => a.UserState == state).FirstOrDefault();

            if (user.UserUniqueID != User.Identity.GetUserId())
            {
                return(Redirect("http://appurl.com/userintegration/integrate/"));
            }

            Yellowant ya = new Yellowant
            {
                AppKey      = "Rvpy9UMwy4wfOR0HHohOoCdXk3IIl2n4BhzpMC28",
                AppSecret   = "9ZjwhuaBmFS1Sq08QHDkWay9pBbLYXsbMRSBzOXV6pj7pCILsWDNHl3vfChwgnD90KpNqEJxottOlJp5esefQGVFRKwq13hgrVO2iKDADhpjFg8nytgyeSEC43ikl0Uq",
                RedirectURI = "http://appurl.com/userintegration/oauthredirect",
                AccessToken = ""
            };
            dynamic AccessToken = ya.GetAccessToken(code);

            string    token = AccessToken.access_token;
            Yellowant yan   = new Yellowant
            {
                AccessToken = token
            };

            dynamic         user_integration = yan.CreateUserIntegration();
            dynamic         user_profile     = yan.GetUserProfile();
            UserIntegration integration      = new UserIntegration {
                YellowantUserID           = user.UserUniqueID,
                IntegrationID             = user_integration["user_application"],
                InvokeName                = user_integration["user_invoke_name"],
                YellowantIntegrationToken = token,
                YellowantTeamSubdomain    = "temp"
            };

            db.UserIntegrationContext.Add(integration);
            db.SaveChanges();
            return(Redirect("http://appurl.com/userintegration/integrate/"));
        }
Beispiel #18
0
 public void UpdateUserPageVisit(int recordId)
 {
     UserIntegration.UpdateUserPageVisit(recordId);
 }
Beispiel #19
0
 public int UpdateUserPassword(User theUser)
 {
     return(UserIntegration.UpdateUserPassword(theUser));
 }
Beispiel #20
0
 public User GetUserByLoginCredentials(User theUser)
 {
     return(UserIntegration.GetUserByLoginCredentials(theUser));
 }
Beispiel #21
0
 public User GetUserByUserReferenceID(int UserReferenceID)
 {
     return(UserIntegration.GetUserByUserReferenceID(UserReferenceID));
 }
Beispiel #22
0
 public User GetUserByLoginNameGuset(string loginName)
 {
     return(UserIntegration.GetUserByLoginNameGuset(loginName));
 }
Beispiel #23
0
 public User GetUserByID(int userID)
 {
     return(UserIntegration.GetUserByID(userID));
 }
Beispiel #24
0
 public int InsertUserPageVisit(int logId, int pageId)
 {
     return(UserIntegration.InsertUserPageVisit(logId, pageId));
 }
Beispiel #25
0
 public int UpdateUser(User theUser)
 {
     return(UserIntegration.UpdateUser(theUser));
 }
Beispiel #26
0
 public int InsertUser(User theUser)
 {
     return(UserIntegration.InsertUser(theUser));
 }
Beispiel #27
0
 public void Add(UserIntegration entity)
 {
     _fakeUserIntegrations.Add(entity);
 }
Beispiel #28
0
 public List <ErrorLog> GetErrorLogs()
 {
     return(UserIntegration.GetErrorLogs());
 }
Beispiel #29
0
        public void Update(UserIntegration entity)
        {
            var entityIndex = _fakeUserIntegrations.IndexOf(entity);

            _fakeUserIntegrations[entityIndex] = entity;
        }
Beispiel #30
0
 public List <User> GetUserList()
 {
     return(UserIntegration.GetUserList());
 }