public ActionResult Edit(string id) { int userId = WebSecurity.GetUserId(WebSecurity.CurrentUserName); var userProfile = _userContext.UserProfiles.First(x => x.UserId == userId); UserData userData = new UserData(); userData.PublicKey = userProfile.PublicKey; userData.Timestamp = DateTime.Now; userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + id + userData.Timestamp + userProfile.PrivateKey); ContactEndpoint c = new ContactEndpoint(); var contact = c.GetContact(id, userData); GroupEndpoint g = new GroupEndpoint(); userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/1/9999/true" + userData.Timestamp + userProfile.PrivateKey); var groups = g.GetGroups(1, 9999, userData); var currentGroup = groups.FirstOrDefault(gr => gr._id == contact.contact.parentId); ViewBag.Groups = groups; ViewBag.GroupName = (currentGroup == null ? "---" : currentGroup.name); return(View(contact)); }
public async Task GetGroups() { var groups = await GroupEndpoint.GetGroups("English"); Assert.NotNull(groups); Assert.NotNull(groups.List); Assert.NotEmpty(groups.List); }
public ActionResult Create() { int id = WebSecurity.GetUserId(WebSecurity.CurrentUserName); var userProfile = _userContext.UserProfiles.First(x => x.UserId == id); Contact c = new Contact(); GroupEndpoint g = new GroupEndpoint(); UserData userData = new UserData(); userData.PublicKey = userProfile.PublicKey; userData.Timestamp = DateTime.Now; userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/1/9999/true" + userData.Timestamp + userProfile.PrivateKey); ViewBag.Groups = g.GetGroups(1, 9999, userData); return(View(c)); }
public ActionResult Index(string searchQuery, string searchScope, int?pageNumber, int pageSize = 12) { int id = WebSecurity.GetUserId(WebSecurity.CurrentUserName); var userProfile = _userContext.UserProfiles.First(x => x.UserId == id); searchScope = "all"; if (string.IsNullOrWhiteSpace(userProfile.PrivateKey) || string.IsNullOrWhiteSpace(userProfile.PublicKey)) { TempData["Notification"] = new Notification("Please provide access keys that have been sent you by email", Nature.warning); return(RedirectToAction("Settings", "Account")); } pageNumber = pageNumber ?? 1; GroupEndpoint g = new GroupEndpoint(); UserData userData = new UserData(); userData.PublicKey = userProfile.PublicKey; userData.Timestamp = DateTime.Now; List <Group> result; if (string.IsNullOrWhiteSpace(searchQuery) || searchScope == null) { userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + pageNumber.Value + "/" + pageSize + "/true" + userData.Timestamp + userProfile.PrivateKey); result = g.GetGroups(pageNumber.Value, pageSize, userData); } else { userData.GenerateAuthenticationHash(userProfile.PrivateKey + userProfile.PublicKey + "GET/contact/" + searchScope + "/" + searchQuery + "/" + pageNumber.Value + "/" + pageSize + "/true" + userData.Timestamp + userProfile.PrivateKey); result = g.GetFilteredGroups(searchScope, searchQuery, pageNumber.Value, pageSize, userData); } ViewBag.SearchQuery = searchQuery; return(View(result)); }