// 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)); } }
public void Delete(UserIntegration entity) { var userIntegration = _fakeUserIntegrations.FirstOrDefault(p => p.UserID == entity.UserID && p.IntegrationTypeID == entity.IntegrationTypeID); _fakeUserIntegrations.Remove(userIntegration); }
public void Update(UserIntegration entity) { DbEntityEntry dbEntityEntry = DbContext.Entry(entity); if (dbEntityEntry.State == EntityState.Detached) { DbSet.Attach(entity); } dbEntityEntry.State = EntityState.Modified; }
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(); } }
public string GeneratePassword() { try { return(UserIntegration.GeneratePassword()); } catch (Exception ex) { throw (new Exception(MethodBase.GetCurrentMethod().DeclaringType.ToString() + "." + (new System.Diagnostics.StackFrame()).GetMethod().Name, ex)); } }
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)); } }
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)); }
public void Add(UserIntegration entity) { DbEntityEntry dbEntityEntry = DbContext.Entry(entity); if (dbEntityEntry.State != EntityState.Detached) { dbEntityEntry.State = EntityState.Added; } else { DbSet.Add(entity); } }
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); } }
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); }
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)); } }
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/")); }
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/")); }
public void UpdateUserPageVisit(int recordId) { UserIntegration.UpdateUserPageVisit(recordId); }
public int UpdateUserPassword(User theUser) { return(UserIntegration.UpdateUserPassword(theUser)); }
public User GetUserByLoginCredentials(User theUser) { return(UserIntegration.GetUserByLoginCredentials(theUser)); }
public User GetUserByUserReferenceID(int UserReferenceID) { return(UserIntegration.GetUserByUserReferenceID(UserReferenceID)); }
public User GetUserByLoginNameGuset(string loginName) { return(UserIntegration.GetUserByLoginNameGuset(loginName)); }
public User GetUserByID(int userID) { return(UserIntegration.GetUserByID(userID)); }
public int InsertUserPageVisit(int logId, int pageId) { return(UserIntegration.InsertUserPageVisit(logId, pageId)); }
public int UpdateUser(User theUser) { return(UserIntegration.UpdateUser(theUser)); }
public int InsertUser(User theUser) { return(UserIntegration.InsertUser(theUser)); }
public void Add(UserIntegration entity) { _fakeUserIntegrations.Add(entity); }
public List <ErrorLog> GetErrorLogs() { return(UserIntegration.GetErrorLogs()); }
public void Update(UserIntegration entity) { var entityIndex = _fakeUserIntegrations.IndexOf(entity); _fakeUserIntegrations[entityIndex] = entity; }
public List <User> GetUserList() { return(UserIntegration.GetUserList()); }