public async Task <IActionResult> RecoverPasswordApp([FromBody] emailrequest request) { if (!ModelState.IsValid) { return(BadRequest(new Response { IsSuccess = false, Message = "Bad request" })); } User user = await _userHelper.GetUserAsync(request.Email); if (user == null) { return(BadRequest(new Response { IsSuccess = false, Message = "Error001" })); } string myToken = await _userHelper.GeneratePasswordResetTokenAsync(user); string link = Url.Action("ResetPassword", "Account", new { token = myToken }, protocol: HttpContext.Request.Scheme); _mailHelper.SendMail(request.Email, "Password Recover", $"<h1>Password Recover</h1>" + $"Click on the following link to change your password:<p>" + $"<a href = \"{link}\">Change Password</a></p>"); return(Ok(new Response { IsSuccess = true })); }
public emailrepdetail Emailreportdisplay() { List <emailrep> emailreplist = new List <emailrep>(); emailrepdetail Details = new emailrepdetail(); var emailrepRequestmessage = Request.Content.ReadAsStringAsync(); emailrequest emailrepRequest = JsonConvert.DeserializeObject <emailrequest>(emailrepRequestmessage.Result.ToString()); if (emailrepRequestmessage.Result.ToString() != null && emailrepRequestmessage.Result.ToString() != "") { using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString)) { using (SqlCommand cmd = new SqlCommand("usp_api_Webmessage_EMAIL_FromStudent_Select", con)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@studentcode", SqlDbType.Int).Value = emailrepRequest.studentcode; cmd.Parameters.Add("@fromdate", SqlDbType.DateTime).Value = emailrepRequest.fromdate; cmd.Parameters.Add("@todate", SqlDbType.DateTime).Value = emailrepRequest.todate; SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count > 0) { foreach (DataRow dtrow in dt.Rows) { var slist = new emailrep(); slist.messagetittle = Convert.ToString(dtrow["Messagetittle"]); slist.posteddate = Convert.ToString(dtrow["PostedDate"]); slist.EmailContent = Convert.ToString(dtrow["EmailContent"]); slist.remarks = Convert.ToString(dtrow["remarks"]); emailreplist.Add(slist); } Details.emailrepdetails = emailreplist; return(Details); } else { throw new HttpResponseException(HttpStatusCode.NoContent); } } } } else { throw new HttpResponseException(HttpStatusCode.BadRequest); } }
public async Task <Response> RecoverPasswordAsync(string urlBase, string servicePrefix, string controller, emailrequest emailRequest) { try { string requst = JsonConvert.SerializeObject(emailRequest); StringContent content = new StringContent(requst, Encoding.UTF8, "application/json"); HttpClient client = new HttpClient { BaseAddress = new Uri(urlBase) }; string url = $"{servicePrefix}{controller}"; HttpResponseMessage response = await client.PostAsync(url, content); string answer = await response.Content.ReadAsStringAsync(); Response obj = JsonConvert.DeserializeObject <Response>(answer); return(obj); } catch (Exception ex) { return(new Response { IsSuccess = false, Message = ex.Message, }); } }