/// <summary> /// Delete a message /// </summary> /// <param name="comment"></param> public void DeleteComment(Message message) { //using (NHTransactionScope tx = new NHTransactionScope()) //{ Repository<Message>.Delete(message); // tx.VoteCommit(); //} }
public ActionResult GenerateAndSendNewPassword(string returnUrl) { var resetPasswordModel = new ResetPasswordModel(); try { string hostName = WebHelper.GetHostName(); Site currentSite = siteService.GetSiteByHostName(hostName); if (ModelState.IsValid && TryUpdateModel(resetPasswordModel)) { User user = userService.FindUserByEmail(currentSite, resetPasswordModel.Email); // if the user is found, then go to the landing page or the requested page (ReturnUrl) if (user != null) { string newPassword = authenticationService.ResetPassword(user); string message = string.Format("Hi, your new password is:\r\n{0}\r\n\r\n- Arashi Team", newPassword); //MailMessage mail = EmailService.CreateMailMessage(Context.CurrentSite.Email, new string[] { Context.CurrentSite.Email }, null, null, "Arashi - Password reset", message, Encoding.UTF8, false); try { //EmailService emailService = new EmailService(); //emailService.Send(mail); Message contactMessage = new Message { Site = Context.CurrentSite, To = Context.CurrentSite.Email, From = Context.CurrentSite.Email, Subject = "Arashi - Password reset", Body = message, Type = MessageType.Email }; messageService.Save(contactMessage); ViewData["ResetPasswordSuccessfull"] = "The new password will arrive to your mailbox in a few minutes!"; } catch (Exception ex) { log.Error(ex.ToString()); ViewData["ResetPasswordFailed"] = "Sorry, an error occurred sending the email..."; } return View("ResetPassword", resetPasswordModel); } } } //catch (RulesException ex) //{ // ex.AddModelStateErrors(ModelState, "login"); // return View("ResetPassword", resetPasswordModel); //} catch (Exception ex) { log.Error(ex.ToString()); throw; } ViewData["ResetPasswordFailed"] = "The email address is incorrect or don't belong to a user of the system."; return View("ResetPassword", resetPasswordModel); }