public ActionResult PasswordRecovery(FormCollection collection)
        {
            string username = collection["Username"];

            try
            {
                MembershipUser user        = MembershipService.GetUserByLogin(username);
                string         newPassword = user.ResetPassword();
                EmailBroadcaster.SendEmail(ViewRes.Controllers.Account.PassRecoveryNew, ViewRes.Controllers.Account.PassRecoveryPass + newPassword, user.Email);
                return(RedirectToAction("PasswordRecoverySucceeded"));
            }
            catch
            {
                try
                {
                    MembershipUser user        = MembershipService.GetUserByLogin(MembershipService.GetUserByEmail(username));
                    string         newPassword = user.ResetPassword();
                    EmailBroadcaster.SendEmail(ViewRes.Controllers.Account.PassRecoveryNew, ViewRes.Controllers.Account.PassRecoveryPass + newPassword, user.Email);
                    return(RedirectToAction("PasswordRecoverySucceeded"));
                }
                catch {
                    ModelState.AddModelError(ViewRes.Controllers.Account.UserName, new Exception());
                    return(View());
                }
            }
        }
 public ActionResult Create(User user)
 {
     if (new UsersServices().GetByUserName(User.Identity.Name).Company.CompaniesType.Name == "Customer")
     {
         user.Company_Id = new UsersServices().GetByUserName(User.Identity.Name).Company_Id;
     }
     if (GetAuthorization(user))
     {
         ValidateUserModel(user);
         ImageFileValidation();
         if (ModelState.IsValid)
         {
             if (_userService.Add(user))
             {
                 UploadImageToServer(user.Id);
                 _userService.SaveChanges();
                 EmailBroadcaster.SendEmail(ViewRes.Controllers.Users.UserWelcome, ViewRes.Controllers.Users.Message, user.Email);
                 return(RedirectToAction("Index"));
             }
         }
         InitializeViews(null);
         return(View(_userViewModel));
     }
     else
     {
         return(RedirectToLogOn());
     }
 }
        private void SendMail(Feedback feedback)
        {
            string Body = "Feedback enviado: \n \n";

            if (feedback.User_Id.HasValue)
            {
                Body += "Usuario: " + feedback.User.FirstName + " " + feedback.User.LastName + "\n" +
                        "Compañía: " + feedback.User.Company.Name + "\n";
            }
            Body += "Fecha: " + DateTime.Now.ToString("dd/MM/yyyy") + "\n" +
                    "Tipo de feedback: " + feedback.FeedbackType.Name + "\n";
            if (feedback.AddComments != "")
            {
                Body += "Sugerencias: " + feedback.AddComments + "\n";
            }
            if (feedback.Comments != "")
            {
                Body += "Comentarios: " + feedback.Comments + "\n";
            }
            foreach (Feature feature in feedback.FeedbackType.Features)
            {
                Score score = feedback.Scores.Where(f => f.Feature_Id == feature.Id).FirstOrDefault();
                if (score != null)
                {
                    Body += "Puntuación para '" + feature.Name + "': " + score.Value + "\n";
                }
            }
            try
            {
                EmailBroadcaster.SendEmail("Feedback enviado desde HRMedinet", Body, "[email protected], [email protected]");
            }
            catch
            {
                ModelState.AddModelError(ViewRes.Controllers.Account.UserName, new Exception());
            }
        }