Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Relationship between Profiles and AspNetUsers: 0 to 0
- builder.Entity<ApplicationUser>()
- .HasOne(b => b.Profile)
- .WithOne(a => a.ApplicationUser)
- .HasForeignKey<ApplicationUser>(b => b.ProfileId);
- public async Task<IActionResult> Register(RegisterViewModel model, string returnUrl = null)
- {
- ViewData["ReturnUrl"] = returnUrl;
- if (ModelState.IsValid)
- {
- var user = new ApplicationUser { UserName = model.Email, Email = model.Email };
- var result = await _userManager.CreateAsync(user, model.Password);
- if (result.Succeeded)
- {
- await _signInManager.SignInAsync(user, isPersistent: false);
- _logger.LogInformation(3, "User created a new account with password.");
- return RedirectToLocal(returnUrl);
- }
- AddErrors(result);
- }
- // If we got this far, something failed, redisplay form
- return View(model);
- }
- namespace Overnight.Models.Security
- {
- public class ApplicationUser : IdentityUser<Guid>
- {
- public string PlainPassword { get; set; }
- public DateTime CreatedAt {get; set;}
- public Nullable<DateTime> UpdatedAt {get; set;}
- public Nullable<DateTime> DeletedAt {get; set;}
- public Int64 ProfileId { get; set; }
- public Profile Profile { get; set; }
- }
- }
- namespace Overnight.Models
- {
- public enum GenderType : byte {
- Unknown = 0,
- Male = 1,
- Female = 2,
- NotApplicable = 9
- }
- public class Profile : BaseEntity<Int64>
- {
- public string FirstName { get; set; }
- public string LastName { get; set; }
- public GenderType Gender { get; set; }
- public Nullable<DateTime> DayOfBirth { get; set; }
- public Nullable<DateTime> LastActivityDate { get; set; }
- //TODO One to One reference for image and adress
- public List<ProfileReview> Reviews { get; set; }
- public List<Blog> Blogs { get; set; }
- public List<Accomodation> Accomodations { get; set; }
- public List<Post> Posts { get; set; }
- public List<Wishlist> Wishlists { get; set; }
- public List<Invoice> Invoices { get; set; }
- public List<Discount> Discounts { get; set; }
- public Security.ApplicationUser ApplicationUser { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement