コード例 #1
0
        // GET: Culture
        public ActionResult CultureCreatePartialSeekerAccount(SeekerAccount model)
        {
            Culture culture = new Culture();
            List<Trait> listItems = new List<Trait>();
            foreach (var prop in from s in culture.GetType().GetProperties() select s)
            {
                if (!prop.PropertyType.Equals(typeof(int)))
                    continue;
                Trait item = new Trait
                {
                    DisplayName = prop.Name,
                    PropertyName = prop.Name
                };
                listItems.Add(item);
            }
            CultureCreateViewModel viewModel = new CultureCreateViewModel
            {
                CreatorType = CultureCreatorType.SeekerAccount,
                CreatorId = model.Id,
                Traits = listItems
            };

            return PartialView("CultureCreatePartial", viewModel);
        }
コード例 #2
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser { UserName = model.Email, Email = model.Email, Role = model.Role,
                 FirstName = model.FirstName, LastName = model.LastName, Age = model.Age};
                var result = await UserManager.CreateAsync(user, model.Password);
                if (result.Succeeded)
                {
                    ApplicationDbContext context = new ApplicationDbContext();
                    SeekerAccount account = new SeekerAccount();
                    account.Id = Guid.NewGuid();
                    context.SeekerAccounts.Add(account);
                    await context.SaveChangesAsync();

                    context.Users.Attach(user);
                    //user.SeekerAccount = account;
                    var entry = context.Entry(user);
                    entry.Reference(e => e.SeekerAccount).CurrentValue = account;
                    //entry.Property(e => e.SeekerAccount).IsModified = true;
                    await context.SaveChangesAsync();

                    await SignInManager.SignInAsync(user, isPersistent:false, rememberBrowser:false);
                    
                    // For more information on how to enable account confirmation and password reset please visit http://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", "Home");
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }
コード例 #3
0
 public ActionResult SeekerAccountPartial(SeekerAccount account)
 {
     return PartialView("SeekerAccountPartial", account);
 }