public void Create(string email, UserDto userDto) { var user = UserAdapter.BuildUser(userDto); var sub = _gUserRepository.Find(usr => usr.Email.Equals(email)).FirstOrDefault(); if (sub != null) { var subs = _userRepository.GetUserById(sub.Id).Subscriber; user.DependsOnAdmin = new List <Subscriber>() { subs }; } var roleUser = _roleRepository.Find(x => x.Name.Equals(RoleConstants.User)).FirstOrDefault(); user.Roles = new List <Role> { roleUser }; _userRepository.AddUser(user); var body = _email.CreateEmailBody(user.UserName, "Subscriber"); _email.SendEmail("Welcome", body, user.Email); }
public async Task <ApiResponse> ForgotPassword([FromBody] JObject req) { var _res = new ApiResponse(); try { var email = req["Email"].ToObject <string>(); if (string.IsNullOrEmpty(email)) { _res.Status = false; _res.Message = "Please enter email address."; return(_res); } var token = _tokenService.TokenGenerateByEmail(email); var resetLink = _siteSettings.BaseUrl + "/ResetPassword?token=" + token; //var resetLink = Url.Action("ResetPassword", "ForgotPassword", new { token = token }, protocol: HttpContext.Request.Scheme); var emailBody = _emailService.CreateEmailBody(resetLink, "ForgotPassword.html"); _emailService.SendMailbyThread(email, "Reset Password", emailBody, null); _res.Status = true; _res.Message = "We have Email your password reset link."; return(_res); } catch (Exception ex) { _res.Status = true; _res.Message = ex.Message.ToString(); return(_res); } }