public async Task <ActionResult> InvitationRegistration(AcceptInvite model, HttpPostedFileBase Avatar)
        {
            var db = new ApplicationDbContext();

            if (ModelState.IsValid)
            {
                var errorMsg = new List <string>();

                //Retrieve the Invitation using the incoming model.Code
                var myInvitation = db.Invitations.FirstOrDefault(i => i.Code == model.Code);
                if (myInvitation.Accepted == true)
                {
                    errorMsg.Add("This invitation has already been accepted...");
                }

                if (DateTime.Now > myInvitation.Expires)
                {
                    errorMsg.Add("This invitation had expired...");
                }


                if (Avatar != null)
                {
                    var fileName = Path.GetFileName(Avatar.FileName);
                    Avatar.SaveAs(Path.Combine(Server.MapPath("~/Uploads/Avatars/"), fileName));
                    model.AvatarPath = "/Uploads/Avatars/" + fileName;
                }

                var user = new ApplicationUser
                {
                    UserName    = model.Email,
                    Email       = model.Email,
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    DisplayName = model.DisplayName,
                    AvatarPath  = model.AvatarPath
                };

                var result = await UserManager.CreateAsync(user, model.Password);

                memberHelp.AddUserToRole(user.Id, "Member");
                houseHelp.AddUserToHousehold(user.Id, myInvitation.HouseholdId);
                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Households", new { id = myInvitation.HouseholdId }));
                }
                AddErrors(result);
            }
            //something went wrong
            return(View(model));
        }
        public ActionResult InvitationRegistration(Guid Code, string Email)
        {
            var newInvite = new AcceptInvite
            {
                Code  = Code,
                Email = Email
            };

            return(View(newInvite));
        }
        public ActionResult AcceptInvite(string code)
        {
            AcceptInvite model = new AcceptInvite();

            string[] Decode      = Cryptography.Decrypt(code).Split('/');
            var      datetime    = Decode[4];
            DateTime CurrentDate = DateTime.Now;
            DateTime tokenDate   = Convert.ToDateTime(datetime);
            var      _Diff       = CurrentDate.Subtract(tokenDate).TotalHours;

            if (_Diff <= 24)
            {
                Guid accountId = new Guid(Decode[2]);
                Guid VendorId;
                if (!string.IsNullOrWhiteSpace(Decode[5]))
                {
                    VendorId = new Guid(Decode[5]);
                }
                else
                {
                    VendorId = new Guid("00000000-0000-0000-0000-000000000000");
                }
                var accDetail = (from a in CommonContext.CommonAccounts where a.Id == accountId select new { a.Name }).SingleOrDefault();
                if (accDetail != null)
                {
                    model.AccountName  = accDetail.Name;
                    model.AccountId    = accountId;
                    model.InvitedEmail = Decode[0];
                    model.Permission   = Convert.ToInt16(Decode[1]);
                    model.Name         = Decode[3];
                    model.VendorId     = VendorId;
                    //TODO: Get system permission from code.  For now, we will default to Government.
                    model.SystemPermission = (SystemPermissions)Enum.Parse(typeof(SystemPermissions), (Convert.ToString(Decode[6])));

                    return(View(model));
                }
                return(RedirectToAction("Index", "Accounts"));
            }
            ViewBag.SucessMessage = "User Invitation Link is Expired.";
            return(View(model));
        }
예제 #4
0
        // Token: 0x060014CF RID: 5327 RVA: 0x00024520 File Offset: 0x00023520
        protected internal override void BuildGraph()
        {
            State      state  = new State("initial");
            State      state2 = new State("safehouse");
            State      state3 = new State("store");
            State      state4 = new State("freeroam");
            State      state5 = new State("lobby");
            State      state6 = new State("recover");
            State      state7 = new State("reset");
            State      state8 = new State("event");
            State      state9 = new State("done");
            ResetProps item   = new ResetProps();
            CloseOnReceive <OnEnterStore>            activity  = new CloseOnReceive <OnEnterStore>(Ports.Gameplay);
            CloseOnReceive <OnReturnToPreviousState> activity2 = new CloseOnReceive <OnReturnToPreviousState>(Ports.Gameplay);
            CloseOnReceive <OnEnterFreeroam>         activity3 = new CloseOnReceive <OnEnterFreeroam>(Ports.Gameplay);
            EnableGadget        item2 = new EnableGadget("Overlay", EnableGadget.HudToggle.Enable);
            EnableGadget        item3 = new EnableGadget("Overlay", EnableGadget.HudToggle.Dispose);
            EnableGadget        item4 = new EnableGadget("PowerupBuffBar", EnableGadget.HudToggle.Dispose);
            EnableGadget        item5 = new EnableGadget("PowerupBuffBar", EnableGadget.HudToggle.Enable);
            EnableLoadingScreen item6 = new EnableLoadingScreen(false);

            state.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Audio, 2215583664u));
            state.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_AI, 1667320711u));
            state.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Frontend, 1039281932u));
            state.Transitions.Add(new Transition("freeroam", activity3));
            state.ExitActivity.Activities.Add(item5);
            state.ExitActivity.Activities.Add(item2);
            state2.EnterActivity.Activities.Add(item4);
            state2.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Audio, 2215583664u));
            state2.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_AI, 1667320711u));
            state2.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Frontend, 1039281932u));
            state2.Transitions.Add(new Transition("store", activity));
            state2.Transitions.Add(new Transition("freeroam", activity3));
            state2.ExitActivity.Activities.Add(item5);
            ClearAllBuff item7 = new ClearAllBuff();

            state3.EnterActivity.Activities.Add(item7);
            state3.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Audio, 1950424019u));
            state3.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Frontend, 2145842197u));
            state3.Transitions.Add(new ReturnTransition(activity2));
            ResetLobby item8 = new ResetLobby();
            CloseOnReceive <OnEnterSafeHouse> activity4 = new CloseOnReceive <OnEnterSafeHouse>(Ports.Gameplay);
            RefreshEvents item9 = new RefreshEvents();
            GetAndTriggerAvailableLevelGifts item10 = new GetAndTriggerAvailableLevelGifts();
            ResetHeat item11 = new ResetHeat();
            EnablePointsOfInterest     item12              = new EnablePointsOfInterest(3312964337u, true);
            ConnectToRoaming           item13              = new ConnectToRoaming();
            LockLocalVehicle           item14              = new LockLocalVehicle(false);
            AssignPowerupConfiguration item15              = new AssignPowerupConfiguration(PowerupConfiguration.kPowerupConfigFreeRoam);
            RechargeAllPowerups        item16              = new RechargeAllPowerups();
            EnterEngagableTriggered    activity5           = new EnterEngagableTriggered(this.manager, Ports.Gameplay);
            EnterEventTriggered        enterEventTriggered = new EnterEventTriggered(Ports.Gameplay);

            enterEventTriggered.EventSessionId    = new OutArgument <long>(this.eventSessionId);
            enterEventTriggered.EventKey          = new OutArgument <uint>(this.eventKey);
            enterEventTriggered.ConnectionSupport = new OutArgument <ConnectionSupport>(this.connectionSupport);
            ExitEngagableTriggered activity6 = new ExitEngagableTriggered(this.manager, Ports.Gameplay);
            Loop loop = new Loop();
            TeleportToTriggered teleportToTriggered = new TeleportToTriggered(Ports.Gameplay);

            teleportToTriggered.Position  = new OutArgument <Vector3>(this.teleportPosition);
            teleportToTriggered.Direction = new OutArgument <Vector3>(this.teleportDirection);
            EnableLoadingScreen item17     = new EnableLoadingScreen(true);
            TeleportTo          teleportTo = new TeleportTo();

            teleportTo.Position  = new InArgument <Vector3>(this.teleportPosition);
            teleportTo.Direction = new InArgument <Vector3>(this.teleportDirection);
            WaitForLoading item18 = new WaitForLoading(0f);

            loop.Activities.Add(teleportToTriggered);
            loop.Activities.Add(item17);
            loop.Activities.Add(teleportTo);
            loop.Activities.Add(item18);
            loop.Activities.Add(item6);
            DisconnectFromRoaming  item19        = new DisconnectFromRoaming();
            EnablePointsOfInterest item20        = new EnablePointsOfInterest(3312964337u, false);
            RunAsyncEvent          runAsyncEvent = new RunAsyncEvent(this.manager);

            runAsyncEvent.EventKey = new InArgument <uint>(Hash.Hash32("events/treasure_hunt_001"));
            AssignPursuitEscalation item21 = new AssignPursuitEscalation(4085894198u);
            EnterLobbyTriggered     enterLobbyTriggered = new EnterLobbyTriggered(Ports.Gameplay);

            enterLobbyTriggered.EventKey = new OutArgument <uint>(this.eventKey);
            state4.EnterActivity.Activities.Add(item8);
            state4.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Audio, 2781049312u));
            state4.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_AI, 2681735821u));
            state4.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Frontend, 3615492632u));
            state4.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_WorldMap, "worldmap_freeroam"));
            state4.EnterActivity.Activities.Add(item);
            state4.EnterActivity.Activities.Add(item9);
            state4.EnterActivity.Activities.Add(item10);
            state4.EnterActivity.Activities.Add(item11);
            state4.EnterActivity.Activities.Add(item12);
            state4.EnterActivity.Activities.Add(item13);
            state4.EnterActivity.Activities.Add(item15);
            state4.EnterActivity.Activities.Add(item16);
            state4.EnterActivity.Activities.Add(item21);
            state4.EnterActivity.Activities.Add(item14);
            state4.EnterActivity.Activities.Add(item18);
            state4.EnterActivity.Activities.Add(item6);
            state4.Transitions.Add(new Transition(activity5));
            state4.Transitions.Add(new Transition("event", enterEventTriggered));
            state4.Transitions.Add(new Transition(activity6));
            state4.Transitions.Add(new Transition("safehouse", activity4));
            state4.Transitions.Add(new Transition("store", activity));
            state4.Transitions.Add(new Transition("reset", runAsyncEvent));
            state4.Transitions.Add(new Transition("lobby", enterLobbyTriggered));
            state4.Transitions.Add(new Transition(loop));
            state4.ExitActivity.Activities.Add(item19);
            state4.ExitActivity.Activities.Add(item20);
            state4.ExitActivity.Activities.Add(item16);
            state7.Transitions.Add(new Transition("freeroam"));
            LoadEventVault loadEventVault = new LoadEventVault();

            loadEventVault.EventKey = new InArgument <uint>(this.eventKey);
            StartStreamingAtEvent startStreamingAtEvent = new StartStreamingAtEvent();

            startStreamingAtEvent.EventKey = new InArgument <uint>(this.eventKey);
            AcceptInvite item22 = new AcceptInvite();
            CloseOnReceive <OnLobbyCancelled> activity7 = new CloseOnReceive <OnLobbyCancelled>(Ports.Gameplay);
            CloseOnReceive <OnLobbyFailed>    activity8 = new CloseOnReceive <OnLobbyFailed>(Ports.Gameplay);
            CloseOnReceive <OnLobbyExited>    activity9 = new CloseOnReceive <OnLobbyExited>(Ports.Gameplay);
            IsStuckInLobby   activity10 = new IsStuckInLobby(0.25f);
            LobbyTick        activity11 = new LobbyTick(0.25f);
            LockLocalVehicle item23     = new LockLocalVehicle(true);

            state5.EnterActivity.Activities.Add(item22);
            state5.EnterActivity.Activities.Add(item23);
            state5.EnterActivity.Activities.Add(item6);
            state5.EnterActivity.Activities.Add(new ChangeBlackBoard(BlackBoardChannel.kBlackBoard_Frontend, 701743214u));
            state5.EnterActivity.Activities.Add(loadEventVault);
            state5.EnterActivity.Activities.Add(startStreamingAtEvent);
            state5.Transitions.Add(new Transition("event", enterEventTriggered));
            state5.Transitions.Add(new Transition("freeroam", activity7));
            state5.Transitions.Add(new Transition("freeroam", activity8));
            state5.Transitions.Add(new Transition("freeroam", activity9));
            state5.Transitions.Add(new Transition("freeroam", activity10));
            state5.Transitions.Add(new Transition(activity11));
            state5.ExitActivity.Activities.Add(item17);
            RunEvent runEvent = new RunEvent(this.manager);

            runEvent.EventSessionId    = new InArgument <long>(this.eventSessionId);
            runEvent.EventKey          = new InArgument <uint>(this.eventKey);
            runEvent.ConnectionSupport = new InArgument <ConnectionSupport>(this.connectionSupport);
            state8.EnterActivity.Activities.Add(item);
            state8.Transitions.Add(new Transition("recover", runEvent));
            CloseOnExitPath activity12 = new CloseOnExitPath(ExitPath.ExitToLobby, false);
            CloseOnExitPath activity13 = new CloseOnExitPath(ExitPath.ExitToFreeroam, true);

            state6.Transitions.Add(new Transition("lobby", activity12));
            state6.Transitions.Add(new Transition("freeroam", activity13));
            state9.EnterActivity.Activities.Add(item3);
            base.InitialState = "initial";
            base.DoneState    = "done";
            base.States.Add(state);
            base.States.Add(state2);
            base.States.Add(state3);
            base.States.Add(state4);
            base.States.Add(state5);
            base.States.Add(state6);
            base.States.Add(state7);
            base.States.Add(state8);
            base.States.Add(state9);
        }
        public async Task <ActionResult> AcceptInvite(AcceptInvite model)
        {
            //Check to see if this user exists in Users
            var existingUser = await CommonContext.Users.Where(m => m.Email == model.InvitedEmail).AnyAsync();

            if (existingUser)
            {
                //Check to see if this user already belongs to the account
                //Users can belong to multiple accounts, we need to filter by accountID and InvitedEmail
                var existingAccountUser = await CommonContext.UserAccounts.Include(x => x.User).Where(m => m.User.Email == model.InvitedEmail && m.AccountId == model.AccountId).AnyAsync();

                if (!existingAccountUser)
                {
                    //Get exists User Detail
                    var user = CommonContext.Users.Where(m => m.Email == model.InvitedEmail).SingleOrDefault();

                    //Get Account detail using accountId
                    var commonAccount = await CommonContext.CommonAccounts.Where(m => m.Id == model.AccountId).SingleOrDefaultAsync();

                    var vendorDetail = await _accountCtx.Vendors.Where(x => x.Id == model.VendorId).SingleOrDefaultAsync();

                    if (commonAccount == null)
                    {
                        ViewBag.SucessMessage = "Account not found";
                        return(View(model));
                    }

                    CommonUserAccount userAccount = new CommonUserAccount();
                    userAccount.CreateUserId = commonAccount.OwnerUserId.Value;
                    userAccount.AccountId    = commonAccount.Id;
                    userAccount.UpdateUserId = commonAccount.OwnerUserId.Value;
                    userAccount.UserId       = user.Id;
                    userAccount.Permissions  = (AccountPermissions)model.Permission;

                    using (var tx = CommonContext.Database.BeginTransaction())
                    {
                        CommonContext.UserAccounts.Add(userAccount);
                        await CommonContext.SaveChangesAsync();

                        tx.Commit();
                    }

                    var accountUser = await _accountCtx.AccountUsers.Where(m => m.Id == user.Id).SingleOrDefaultAsync();

                    if (accountUser == null)
                    {
                        //Create AccountUser
                        accountUser = new AccountUser()
                        {
                            Id        = user.Id,
                            FirstName = user.FirstName,
                            LastName  = user.LastName,
                            Email     = user.Email,
                        };
                        _accountCtx.AccountUsers.Add(accountUser);
                        await _accountCtx.SaveChangesAsync();
                    }

                    if (vendorDetail != null)
                    {
                        AccountUserVendor accountUserVendor = new AccountUserVendor();
                        accountUserVendor.VendorId      = vendorDetail.Id;
                        accountUserVendor.AccountUserId = accountUser.Id;

                        user.Permission = SystemPermissions.Vendor;
                        CommonContext.SaveChanges();

                        using (var tx = _accountCtx.Database.BeginTransaction())
                        {
                            _accountCtx.AccountUserVendors.Add(accountUserVendor);
                            await _accountCtx.SaveChangesAsync();

                            tx.Commit();
                        }
                    }

                    return(RedirectToAction("Index", "Accounts"));
                }
                else
                {
                    ViewBag.SucessMessage = " Already Account user.";
                    return(View(model));
                }
            }
            else
            {
                CreatePassword pwdmodel = new Models.User.CreatePassword();
                pwdmodel.AccountId    = model.AccountId;
                pwdmodel.AccountName  = model.AccountName;
                pwdmodel.InvitedEmail = model.InvitedEmail;
                string[] name = model.Name.Split(' ');
                pwdmodel.FirstName        = name[0];
                pwdmodel.LastName         = name[1];
                pwdmodel.Permission       = model.Permission;
                pwdmodel.VendorId         = model.VendorId;
                pwdmodel.SystemPermission = model.SystemPermission;
                return(View("CreatePassword", pwdmodel));
            }
        }