Пример #1
0
        private int CreateUserDetails(ParticipantRegistration model, string createdBy)
        {
            int userDetailsID = 0;

            using (meetingContext = new OCASIAMeetingContext())
            {
                UserDetail request = new UserDetail()
                {
                    FirstLastName = model.FirstLastName,
                    TitleID       = model.TitleID,
                    FamilyName    = model.FamilyName,
                    GivenName     = model.GivenName,
                    Email         = model.Email,
                    IsActive      = true,
                    IsPublish     = true,
                    CreatedBy     = createdBy,
                    CreatedOn     = DateTime.Now,
                    MeetingID     = model.MeetingID
                };

                meetingContext.UserDetails.Add(request);
                meetingContext.SaveChanges();
                userDetailsID = request.UserDetailID;
                return(userDetailsID);
            }
        }
Пример #2
0
        public async Task <ActionResult> UserRegistration(ParticipantRegistration model)
        {
            MeetingDetails.UserName      = model.GivenName;
            model.MeetingID              = MeetingDetails.MeetingID;
            MeetingDetails.UserDetailsID = dbOperations.RegisterUser(model);
            #region Send Email

            string Emailtemplate = string.Empty;
            Emailtemplate = "~/EmailTemplates/UserSignupConfirmation.html";
            using (StreamReader sr = new StreamReader(HttpContext.Server.MapPath(Emailtemplate)))
                if (sr != null)
                {
                    string        Login    = "******" + Url.Action("Login", "Participant", new { }, "http") + "'>Click</a>";
                    StringBuilder HtmlPage = new StringBuilder();
                    string        HTML     = sr.ReadToEnd();
                    HtmlPage.Append(HTML
                                    .Replace("[UserName]", model.Email)
                                    .Replace("[Email]", model.Email)
                                    .Replace("[Password]", model.Password)
                                    .Replace("[Link]", Login)
                                    );
                    #region Email
                    DAL.ApplicationModels.Extension.SendMail(smtpUsername, smtpPassword, model.Email, Host, Port, EnableSsl, "Olympic Council of Asia Signup Confirmation", HtmlPage.ToString(), "Olympic Council of Asia Signup Confirmation", CCEmail);
                    #endregion
                }
            #endregion
            if (MeetingDetails.UserDetailsID == 0)
            {
                return(View("Error"));
            }
            else if (MeetingDetails.UserDetailsID == -1)
            {
                return(View("AlreadyExists"));
            }


            var user = await UserManager.FindByNameAsync(model.Email);

            if (user != null)
            {
                var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, false, false);

                switch (result)
                {
                case SignInStatus.Success:

                    SetInformationTabDetails(1);

                    return(RedirectToAction("InformationView"));
                }
            }
            return(View(model));
        }
Пример #3
0
        /// <summary>
        /// Step 1 : user creation
        /// </summary>
        /// <param name="model">Registration details</param>
        /// <returns></returns>
        public int RegisterUser(ParticipantRegistration model)
        {
            string createdBy     = string.Empty;
            int    userDetailsID = 0;

            #region Create useer
            using (OCASIAMeetingUOW db = new OCASIAMeetingUOW())
            {
                var res = db.Repository <ApplicationUser>().GetAll().Where(f => f.Email == model.Email).FirstOrDefault();
                if (res == null)
                {
                    var user = new ApplicationUser()
                    {
                        UserName         = model.Email,
                        Email            = model.Email,
                        RoleCustomID     = 3,
                        IsActive         = true,
                        IspasswordActive = true
                    };
                    var userManager = new Microsoft.AspNet.Identity.UserManager <ApplicationUser>(new Microsoft.AspNet.Identity.EntityFramework.UserStore <ApplicationUser>(new OCASIAMeetingContext()));
                    var ures        = userManager.Create(user, model.Password);
                    if (ures.Succeeded)
                    {
                        // userManager.AddClaim(user.Id, new System.Security.Claims.Claim("FullName", model.Email));
                        Passwordhash mdl = new Passwordhash()
                        {
                            UserId   = user.Id,
                            Password = model.Password
                        };
                        db.Repository <Passwordhash>().Add(mdl);
                        db.SaveChanges();
                        createdBy = mdl.UserId;
                    }
                }
                else
                {
                    return(-1);
                }
            }
            #endregion
            if (string.IsNullOrEmpty(createdBy))
            {
                return(userDetailsID);
            }
            userDetailsID = CreateUserDetails(model, createdBy);
            return(userDetailsID);
        }