public JsonResult GetContactDetailsByAjax(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);

            return Json(contact, JsonRequestBehavior.AllowGet);
        }
        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);
        }