public void AddationalInfo(InternalRegisterViewModel model) { try { UserInfo UserInformation = new UserInfo(); UserInformation.Name = model.Name; UserInformation.Address = model.Address; UserInformation.PostCode = model.PostCode; UserInformation.City = model.City; UserInformation.Phone = model.Phone; UserInformation.Gender = model.Gender; UserInformation.Photo = SetProfilePicture(model.Gender); UserInformation.BirthDate = null; var user = Data.Users.FirstOrDefault(x => x.Email == model.Email); UserInformation.UserId = user.Id; UserInformation.CurrentJobTitle = "Not Specified"; UserInformation.CompanyName = "Not Specified"; UserInformation.Skills = "Not Specified"; UserInformation.CurrentStatus = "Not Specified"; UserInformation.Expectation = "Not Specified"; UserInformation.Contribution = "Not Specified"; UserInformation.Email = model.Email; // Note: _data cant access data from database //_data.UserInfo.Add(UserInformation); //_data.SaveChanges(); Data.UserInfo.Add(UserInformation); Data.SaveChanges(); // Temporarily : User will not get any email after registration //obj.ToEmail = model.Email; //obj.EmailSubject = Helpers.Constants.Welcomesubject; //obj.EMailBody = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/Email_Templets/") + "WelcomeEmail" + ".cshtml").ToString(); //var result = _utility.SendEmail(obj); //obj.ToEmail = System.Configuration.ConfigurationManager.AppSettings["Admin"]; //obj.EmailSubject = Helpers.Constants.NewUser; //obj.EMailBody = System.IO.File.ReadAllText(HostingEnvironment.MapPath("~/Email_Templets/") + "NewUserNotification" + ".cshtml").Replace("UserName", model.Name).Replace("UserEmail", model.Email).ToString(); //var result2 = _utility.SendEmail(obj); } catch { throw; } }
public async Task <ActionResult> Register(InternalRegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; //TODO: have to fix for password. 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 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>"); // Note : _UserAccountProfile doesnt work as it has a constructor parameter //_UserAccountProfile.AddationalInfo(model); //_UserAccountProfile.SetUserRole(model.Email); _UserProfile.AddationalInfo(model); _UserProfile.SetUserRole(model.Email); Email_Service_Model email = new Email_Service_Model(); email.ToEmail = System.Configuration.ConfigurationManager.AppSettings["BccEmail"]; email.EmailSubject = $"{model.Name} signed up."; email.EMailBody = $"Name: {model.Name}. Email:{model.Email}"; var emailmanager = new UtilityManager(); emailmanager.SendEmail(email); return(RedirectToAction("New_Registration", new { Id = user.Id })); } logger.Error($"Error signing up. {model.Email}"); AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }