예제 #1
0
        public async Task <ActionResult> RegisterMember(CustomerRegisterMember model, HttpPostedFileBase imagePath)
        {
            if (ModelState.IsValid)
            {
                var role = new Microsoft.AspNet.Identity.EntityFramework.IdentityRole();
                var user = new Domain.Entities.Member
                {
                    UserName    = model.Email,
                    Email       = model.Email,
                    cin         = model.cin,
                    firstName   = model.firstName,
                    lastName    = model.lastName,
                    PhoneNumber = model.PhoneNumber,
                    gender      = model.gender,
                    Address     = model.Address,
                    password2   = model.Password,
                    imagePath   = imagePath.FileName,
                    RoleUser    = "******"
                };



                imagePath.SaveAs(System.IO.Path.Combine(Server.MapPath("~/Images/"), imagePath.FileName));


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

                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 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("HomeManager", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(RedirectToAction("RegisterMember", "Account"));
        }
 public override bool IsId(Member member)
 {
     return member.Name == "Id";
 }
 public override string GetComponentColumnPrefix(Member member)
 {
     return string.Format("{0}_", NameConventions.GetTableName(member.PropertyType));
 }
 public override string GetComponentColumnPrefix(Member member)
 {
     return string.Format("{0}_", Regex.Replace(member.Name, "([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))", "$1_").ToUpper());
 }