public string[] DeleteBucketListItem(int bucketListDbId, string encodedUser, string encodedToken) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); string[] result = null; try { string decodedToken = Utility.DecodeClientBase64String(encodedToken); string decodedUserName = Utility.DecodeClientBase64String(encodedUser); IList<string> parameters = new List<string>(); parameters.Add(bucketListDbId.ToString()); CommonCode.Log(null, bld, "DeleteBucketListItem", parameters); if (ProcessToken(decodedUserName, decodedToken)) { bld.DeleteBucketListItem(bucketListDbId); result = Utility.GetValidTokenResponse(); } else result = Utility.GetInValidTokenResponse(); } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return result; }
public string[] GetBucketListItems(string encodedUserName, string encodedSortString, string encodedToken) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); string[] result = null; try { string decodedUserName = Utility.DecodeClientBase64String(encodedUserName); string decodedSortString = Utility.DecodeClientBase64String(encodedSortString); string decodedToken = Utility.DecodeClientBase64String(encodedToken); IList<string> parameters = new List<string>(); parameters.Add(decodedUserName); parameters.Add(decodedSortString); CommonCode.Log(null, bld, "GetBucketListItems", parameters); if (ProcessToken(decodedUserName, decodedToken)) result = bld.GetBucketList(decodedUserName, decodedSortString); else { result = Utility.GetInValidTokenResponse(); } } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return result; }
public void User_DeleteUserBucketListItems_UserName_DeleteMultiple_Test() { var userName = "******"; IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); List <User> users = new List <User>(); var userId1 = bd.AddUser(GetUser("token1", userName)); var userId2 = bd.AddUser(GetUser("token2", userName)); var userId3 = bd.AddUser(GetUser("token3", userName)); bd.AddToken(userId1, "token1"); bd.AddToken(userId2, "token2"); bd.AddToken(userId3, "token3"); var bucketListItems = GetBucketListItems(); foreach (var bucketListItem in bucketListItems) { bd.UpsertBucketListItem(bucketListItem, userName); } AssertUsersExist(true, true, bd, userName); bd.DeleteUserBucketListItems(userName, false); AssertUsersExist(false, true, bd, userName); }
public string[] GetBucketListItems(string encodedUserName, string encodedSortString, string encodedToken) { IBucketListData bld = null; string[] result = null; try { bld = new BucketListData(Utilities.GetDbSetting()); string decodedUserName = Utilities.DecodeClientBase64String(encodedUserName); string decodedSortString = Utilities.DecodeClientBase64String(encodedSortString); string decodedToken = Utilities.DecodeClientBase64String(encodedToken); //LogParameters(); if (ProcessToken(decodedUserName, decodedToken)) { result = bld.GetBucketList(decodedUserName, decodedSortString); } else { result = Utilities.GetInValidTokenResponse(); } } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return(result); }
public void User_DeleteUserBucketListItems_OnlyDeleteBucketListItems_Test() { var userName = "******"; IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); List <User> users = new List <User>(); var userId1 = bd.AddUser(GetUser("token1", userName)); var userId2 = bd.AddUser(GetUser("token2", userName)); var userId3 = bd.AddUser(GetUser("token3", userName)); bd.AddToken(userId1, "token1"); bd.AddToken(userId2, "token2"); bd.AddToken(userId3, "token3"); var bucketListItems = GetBucketListItems(); foreach (var bucketListItem in bucketListItems) { bd.UpsertBucketListItem(bucketListItem, userName); } AssertUsersExist(true, true, bd, userName); bd.DeleteUserBucketListItems(userName, true); var bucketListItemSaved = bd.GetBucketList(userName); Assert.IsFalse(bucketListItemSaved.Count > 0); var savedUsers = bd.GetUsers("testUser"); Assert.IsTrue(savedUsers.Count > 0); }
public void GetSystemSystemStatisticsGetSystemBuildStatisticsHappyPath_Test() { //set up ------------------------------------------------------ var dbContext = this.GetDbContext(); var now = DateTime.Now; var systemStatisticsToSave = new SystemStatistics { WebsiteIsUp = true, DatabaseIsUp = true, AzureFunctionIsUp = true, Created = now }; dbContext.SystemStatistics.Add(systemStatisticsToSave); dbContext.SaveChanges(); //test --------------------------------------------------------- IBucketListData bd = new BucketListData(dbContext, this.userHelper); var systemStatistics = bd.GetSystemStatistics(); Assert.IsNotNull(systemStatistics); var systemStatistic = systemStatistics .OrderByDescending(x => Convert.ToDateTime(x.Created)) .FirstOrDefault(); Assert.AreEqual(systemStatistic.WebSiteIsUp, systemStatisticsToSave.WebsiteIsUp); Assert.AreEqual(systemStatistic.DatabaseIsUp, systemStatisticsToSave.DatabaseIsUp); Assert.AreEqual(systemStatistic.AzureFunctionIsUp, systemStatisticsToSave.AzureFunctionIsUp); Assert.AreEqual(systemStatistic.Created, systemStatisticsToSave.Created.ToString()); //clean up ------------------------------------------------------ dbContext.Remove(systemStatisticsToSave); dbContext.SaveChanges(); }
public void GetSystemBuildStatisticsHappyPath_Test() { //set up ------------------------------------------------------ var dbContext = this.GetDbContext(true); var now = DateTime.Now; var buildStatisticsToSave = new BuildStatistics { Start = now, End = now.AddMinutes(1), BuildNumber = "123", Status = "Succeeded", Type = "CICD Pipeline - Website" }; dbContext.BuildStatistics.Add(buildStatisticsToSave); dbContext.SaveChanges(); //test --------------------------------------------------------- IBucketListData bd = new BucketListData(dbContext, this.userHelper); var buildStatistics = bd.GetSystemBuildStatistics(); Assert.IsNotNull(buildStatistics); var buildStatistic = buildStatistics .OrderByDescending(x => Convert.ToDateTime(x.Start)) .FirstOrDefault(); Assert.AreEqual(buildStatistic.Start, buildStatisticsToSave.Start.ToString()); Assert.AreEqual(buildStatistic.End, buildStatisticsToSave.End.ToString()); Assert.AreEqual(buildStatistic.BuildNumber, buildStatisticsToSave.BuildNumber); Assert.AreEqual(buildStatistic.Status, buildStatisticsToSave.Status); //clean up ------------------------------------------------------ dbContext.Remove(buildStatisticsToSave); dbContext.SaveChanges(); }
public string[] GetBucketListItems(string encodedUserName, string encodedSortString, string encodedToken) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); string[] result = null; try { string decodedUserName = Utility.DecodeClientBase64String(encodedUserName); string decodedSortString = Utility.DecodeClientBase64String(encodedSortString); string decodedToken = Utility.DecodeClientBase64String(encodedToken); IList <string> parameters = new List <string>(); parameters.Add(decodedUserName); parameters.Add(decodedSortString); CommonCode.Log(null, bld, "GetBucketListItems", parameters); if (ProcessToken(decodedUserName, decodedToken)) { result = bld.GetBucketList(decodedUserName, decodedSortString); } else { result = Utility.GetInValidTokenResponse(); } } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return(result); }
public string[] GetDaily(string encodedUser, string encodedToken, bool isNasdaq) { IBucketListData bld = null; string[] result = null; try { bld = new BucketListData(Utilities.GetDbSetting()); string decodedUserName = Utilities.DecodeClientBase64String(encodedUser); string decodedToken = Utilities.DecodeClientBase64String(encodedToken); //LogParameters(); if (ProcessToken(decodedUserName, decodedToken)) { GetDailyPrice gdp = new GetDailyPrice(); // TODO - do something with bool result? bool goodPull = gdp.GetDailySpreadsheet(isNasdaq); } else { result = Utilities.GetInValidTokenResponse(); } } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return(result); }
//TODO - unncomment before official release public static void LogBrowser(BrowserData bd) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); int browserLogId = bld.LogBrowser(bd); foreach (System.Collections.DictionaryEntry kvp in bd.Capabilities) { bld.LogBrowserCapability(browserLogId, kvp.Key.ToString(), kvp.Value.ToString()); } }
public ActionResult Desktop() { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); IList <string> parameters = new List <string>(); parameters.Add("Making Call"); CommonCode.Log(null, bld, "BucketListController.Desktop()", parameters); return(View()); }
public void User_AddToken_UserDoesNotExist_Test() { RemoveTestUser(); var unknownUserId = -12521; IBucketListData bd = new BucketListData(this.GetDbContext(), this.userHelper); bd.AddToken(unknownUserId, this.Token); // NOTE: RecordDoesNotExistException is expected }
public void User_DeleteUser_UserDoesNotExist_Test() { RemoveTestUser(); var unknownUserId = -12521; IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); bd.DeleteUser(unknownUserId); // NOTE: RecordDoesNotExistException is expected }
public ActionResult WelcomePage() { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); IList<string> parameters = new List<string>(); parameters.Add("Making Call"); CommonCode.Log(null, bld, "RequestController.WelcomePage()", parameters); CommonCode.LogBrowser(GetBrowserData()); return View(); }
public ActionResult WelcomePage() { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); IList <string> parameters = new List <string>(); parameters.Add("Making Call"); CommonCode.Log(null, bld, "RequestController.WelcomePage()", parameters); CommonCode.LogBrowser(GetBrowserData()); return(View()); }
public void BucketListItem_AddBucketListItem_UserDoesNotExist_Test() { // set up ------------------------------------------------------ RemoveTestUser(); IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); var bucketListItemToSave = GetBucketListItem(); // test --------------------------------------------------------- bd.UpsertBucketListItem(bucketListItemToSave, "NonExistantUser"); // NOTE: RecordDoesNotExistException is expected }
public void BucketListItem_DeleteBucketListItem_UserDoesNotExist_Test() { // set up ------------------------------------------------------ RemoveTestUser(); IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); // test --------------------------------------------------------- var nonExistantBucketListItemId = -12412; bd.DeleteBucketListItem(nonExistantBucketListItemId); // NOTE: RecordDoesNotExistException is expected }
public void User_DeleteUser_UserName_DeleteMultiple_Test() { var userName = "******"; IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); bd.AddToken(bd.AddUser(GetUser("token1", userName)), "token1"); bd.AddToken(bd.AddUser(GetUser("token2", userName)), "token2"); bd.AddToken(bd.AddUser(GetUser("token3", userName)), "token3"); AssertUsersExist(true, false, bd, userName); bd.DeleteUserBucketListItems(userName, false); AssertUsersExist(false, false, bd, userName); }
public string[] UpsertBucketListItemV2(string encodedBucketListItems, string encodedUser, string encodedToken) { IBucketListData bld = null; string[] result = null; try { bld = new BucketListData(Utilities.GetDbSetting()); string decodedBucketListItems = Utilities.DecodeClientBase64String(encodedBucketListItems); string decodedToken = Utilities.DecodeClientBase64String(encodedToken); string decodedUserName = Utilities.DecodeClientBase64String(encodedUser); decodedBucketListItems = decodedBucketListItems.Trim(','); decodedBucketListItems = decodedBucketListItems.Trim(';'); string[] items = decodedBucketListItems.Split(','); //HACK - needed a demo user quick and I didn't want any changes if (!string.IsNullOrEmpty(decodedUserName) && decodedUserName.Equals("demouser")) { result = Utilities.GetValidTokenResponse(); } else { //LogParameters(); if (ProcessToken(decodedUserName, decodedToken)) { bld.UpsertBucketListItemV2(items); result = Utilities.GetValidTokenResponse(); } else { result = Utilities.GetInValidTokenResponse(); } } } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return(result); }
public string[] GetDashboard() { IBucketListData bld = null; string[] results = null; try { bld = new BucketListData(Utilities.GetDbSetting()); results = bld.GetDashboard(); } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return(results); }
public string[] UpsertBucketListItem(string encodedBucketListItems, string encodedUser, string encodedToken) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); string[] result = null; try { string decodedBucketListItems = Utility.DecodeClientBase64String(encodedBucketListItems); string decodedToken = Utility.DecodeClientBase64String(encodedToken); string decodedUserName = Utility.DecodeClientBase64String(encodedUser); decodedBucketListItems = decodedBucketListItems.Trim(','); decodedBucketListItems = decodedBucketListItems.Trim(';'); string[] items = decodedBucketListItems.Split(','); IList <string> parameters = new List <string>(); foreach (string bucketListItem in items) { parameters.Add(bucketListItem); } CommonCode.Log(null, bld, "UpsertBucketListItem", parameters); if (ProcessToken(decodedUserName, decodedToken)) { bld.UpsertBucketListItem(items); result = Utility.GetValidTokenResponse(); } else { result = Utility.GetInValidTokenResponse(); } } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return(result); }
public void BucketListItem_HappyPath_Test() { // set up ------------------------------------------------------ RemoveTestUser(); var user = GetUser("token"); IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); var bucketListItemToSave = GetBucketListItem(); // test --------------------------------------------------------- var userId = bd.AddUser(user); bd.UpsertBucketListItem(bucketListItemToSave, user.UserName); var savedBucketListItem = bd.GetBucketList(user.UserName).FirstOrDefault(); // we have a saved object that object matches our created object Assert.IsNotNull(savedBucketListItem); Assert.AreEqual(bucketListItemToSave.Name, savedBucketListItem.Name); Assert.AreEqual(bucketListItemToSave.Created, savedBucketListItem.Created); Assert.AreEqual(bucketListItemToSave.Category, savedBucketListItem.Category); Assert.AreEqual(bucketListItemToSave.Achieved, savedBucketListItem.Achieved); Assert.AreEqual(bucketListItemToSave.Latitude, savedBucketListItem.Latitude); Assert.AreEqual(bucketListItemToSave.Longitude, savedBucketListItem.Longitude); // we can update that object and save it // TODO - upsert update part not working...fix savedBucketListItem.Name = savedBucketListItem.Name + " modified"; bd.UpsertBucketListItem(savedBucketListItem, user.UserName); var savedBucketListItemUpdated = bd.GetBucketList(user.UserName).FirstOrDefault(); Assert.AreEqual(savedBucketListItem.Name, savedBucketListItemUpdated.Name); // we can delete the bucket list item bd.DeleteBucketListItem(savedBucketListItemUpdated.Id.Value); var deletedBucketListItem = bd.GetBucketList(user.UserName).FirstOrDefault(); Assert.IsNotNull(savedBucketListItem); //clean up user bd.DeleteUser(userId); }
public void LogMsgHappyPath_Test() { var dbContext = this.GetDbContext(); IBucketListData bd = new BucketListData(dbContext, this.userHelper); //test ---------------------------- var msg = "I am a log message"; bd.LogMsg(msg); dbContext.SaveChanges(); var logModel = dbContext.Log .Where(x => x.LogMessage == msg) .FirstOrDefault(); Assert.IsNotNull(logModel); Assert.AreEqual(msg, logModel.LogMessage); //clean up ------------------------------------------------------ dbContext.Remove(logModel); dbContext.SaveChanges(); }
public void User_HappyPath_Test() { RemoveTestUser(); var token = "token"; var user = GetUser(token); IBucketListData bd = new BucketListData(this.GetDbContext(true), this.userHelper); var userId = bd.AddUser(user); bd.AddToken(userId, token); var savedUser = bd.GetUser(userId); Assert.AreEqual(user.UserName, savedUser.UserName); Assert.AreEqual(user.Password, savedUser.Password); Assert.AreEqual(user.Salt, savedUser.Salt); Assert.AreEqual(user.Email, savedUser.Email); Assert.AreEqual(token, savedUser.Token); bd.DeleteUser(savedUser.UserId); }
public string[] UpsertBucketListItem(string encodedBucketListItems, string encodedUser, string encodedToken) { IBucketListData bld = new BucketListData(Utility.GetAppSetting(BucketListConstants.DB_CONN)); string[] result = null; try { string decodedBucketListItems = Utility.DecodeClientBase64String(encodedBucketListItems); string decodedToken = Utility.DecodeClientBase64String(encodedToken); string decodedUserName = Utility.DecodeClientBase64String(encodedUser); decodedBucketListItems = decodedBucketListItems.Trim(','); decodedBucketListItems = decodedBucketListItems.Trim(';'); string[] items = decodedBucketListItems.Split(','); IList<string> parameters = new List<string>(); foreach (string bucketListItem in items) parameters.Add(bucketListItem); CommonCode.Log(null, bld, "UpsertBucketListItem", parameters); if (ProcessToken(decodedUserName, decodedToken)) { bld.UpsertBucketListItem(items); result = Utility.GetValidTokenResponse(); } else result = Utility.GetInValidTokenResponse(); } catch (Exception e) { bld.LogMsg("Error: " + e.Message + ", trace: " + e.StackTrace.ToString()); } return result; }