public ActionResult Submit(FormCollection collection)
        {
            var id = User.Identity as ClaimsIdentity;
            if (id != null)
            {
                var claims = id.Claims;
                var data = claims.GetClaimsInfo();

                data.ConnectwiseID = collection["ConnectwiseID"];

                var cw = IOCContainer.Resolve<ICWAdapter>();

                if (cw.CheckMemberIDExists(data.ConnectwiseID))
                {
                    var mgr = new UserManager();
                    var user = new User { IsActive = true, MemberSince = DateTime.Now, EmailAddress = data.EmailAddress, DisplayName = data.ConnectwiseID, IdentityProviderKey = data.ProviderKey, IdentityProviderName = data.IdentityProviderName };
                    mgr.RegisterNewUser(user);
                }
                else
                {
                    ViewBag.ErrorMessage = "Unknown Connectwise user";
                    return View("Index", data);
                }
            }

            return RedirectToAction("Index", "Home");
        }
Beispiel #2
0
 //
 // GET: /User/
 public ActionResult ViewProfile()
 {
     var mgr = new UserManager();
     var id = User.Identity as ClaimsIdentity;
     if (id != null)
     {
         var claims = id.Claims;
         var data = claims.GetClaimsInfo();
         if (!mgr.UserExists(data.IdentityProviderName, data.ProviderKey))
             return RedirectToAction("Index", "RegisterUser");
         var user = mgr.GetUserByKey(data.IdentityProviderName, data.ProviderKey);
         ViewBag.Username = user.DisplayName;
         ViewBag.ProviderName = user.IdentityProviderName;
         ViewBag.MemerSince = user.MemberSince.GetValueOrDefault().ToString("mm/dd/yy");
     }
     return View();
 }