public HttpResponseMessage AdminResetPassword([FromBody] int id) { var authHeader = this.Request.Headers.GetValues("Authorization").FirstOrDefault(); var token = authHeader.Substring("Bearer ".Length); var handler = new JwtSecurityTokenHandler(); var jsonToken = handler.ReadToken(token); var tokenS = handler.ReadToken(token) as JwtSecurityToken; var UserName = tokenS.Claims.First(claim => claim.Type == "UserName").Value; var r = UBL.AdminResetPassword(id, UserName); if (!r) { return(this.Request.CreateResponse(HttpStatusCode.InternalServerError)); } else { var model = UBL.Details(id); #region Email string body = string.Empty; using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Views/EmailTemplates/AdminResetPassword.html"))) { body = reader.ReadToEnd(); } body = body.Replace("{FullName}", model.FullName); body = body.Replace("{UserName}", model.UserName); body = body.Replace("{Password}", "!234s6789"); Emails Email = new Emails() { FromEmail = ConfigurationManager.AppSettings["AdminEmail"].ToString(), ToEmail = model.Email, SubjectEmail = "Su contraseña de OasisAlajuela.com ha sido restablecida", BodyEmail = body }; MailMessage mm = new MailMessage(Email.FromEmail, Email.ToEmail) { Subject = Email.SubjectEmail, Body = Email.BodyEmail, IsBodyHtml = true, BodyEncoding = Encoding.GetEncoding("utf-8") }; SmtpClient smtp = new SmtpClient(); smtp.Send(mm); #endregion return(this.Request.CreateResponse(HttpStatusCode.OK, r)); } }