public static void SendWelcomeMessage(UserViewModel userProfile)
        {
            var mailDefinition = new MailDefinition
                {
                    From = "*****@*****.**",
                    Subject = "Welcome to Navasthala",
                    IsBodyHtml = true
                };
            var replacements = new ListDictionary
                {
                    {"<%LastName%>", userProfile.LastName},
                    {"<%UserName%>", userProfile.UserName}
                };

            var path = AppDomain.CurrentDomain.BaseDirectory + @"\Mail\WelcomeMail.html";
            var body = System.IO.File.ReadAllText(path);
            var mail = mailDefinition.CreateMailMessage(userProfile.Email,replacements,body,new Control());
            GetSmtpServer().Send(mail);
        }
        public static void SendPasswordResetMail(string token, UserViewModel userProfile)
        {
            var mailDefinition = new MailDefinition
            {
                From = "*****@*****.**",
                Subject = "Password reset mail",
                IsBodyHtml = true
            };
            var replacements = new ListDictionary
                {
                    {"<%LastName%>", userProfile.LastName},
                    {"<%Token%>", token}
                };

            var path = AppDomain.CurrentDomain.BaseDirectory + @"\Mail\PasswordResetMail.html";
            var body = System.IO.File.ReadAllText(path);
            var mail = mailDefinition.CreateMailMessage(userProfile.Email, replacements, body, new Control());
            GetSmtpServer().Send(mail);
        }
        public ActionResult UpdateUser(UserViewModel viewModel, FormCollection formCollection)
        {
            var operation = formCollection["oper"];
            if (operation.Equals("edit"))
            {
                var user = _context.UserProfiles.FirstOrDefault(p => p.UserId == viewModel.UserId);
                if (user != null)
                {
                    var roleProvider = (SimpleRoleProvider)Roles.Provider;

                    roleProvider.RemoveUsersFromRoles(new[]{user.UserName},roleProvider.GetRolesForUser(user.UserName));
                    roleProvider.AddUsersToRoles(new[] { user.UserName }, new[] { viewModel.Role.TrimStart() });
                    _context.SaveChanges();

                    user.FirstName = viewModel.FirstName;
                    user.LastName = viewModel.LastName;
                    user.Email = viewModel.Email;
                    user.DateOfBirth = viewModel.DateOfBirth;

                    _context.SaveChanges();
                }
            }

            if (operation.Equals("del"))
            {
                var user = _context.UserProfiles.FirstOrDefault(p => p.UserId == viewModel.UserId);
                user.IsActive = false;
                _context.SaveChanges();
            }

            return null;
        }
 public ActionResult ManageUsers()
 {
     SetRoles();
      var vm = new UserViewModel();
     return View("ManageUsersView",vm);
 }