public void SendNotification(string author, string message)
        {
            PointerdbEntities db = new PointerdbEntities();
            SignalRMessageTable OBJM = new SignalRMessageTable()
            {
                 Name=author,
                  message = message
            };

            string password = PasswordGenerator.GeneratePassword("8").ToString(); 
            string string1 = "Hi Firstname and lastname, An Account has been created for you by PointerWebApp.com ";
            string string2 = "The login information for apartment: apartment#: is below";
            string string3 = "Username: EmailAddress";
            string string4 = "Temporary password: "******"Click the on this link and follow the instructions to initiate your account. ";
            string string6 = "Company Description";
            string string7 = "Find more information...";

            string x = string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n", string1, string2, string3, string4, string5, string6, string7);

            Gmail gmail = new Gmail("pointerwebapp", "Dmc10040!");
            MailMessage msg = new MailMessage("*****@*****.**", "*****@*****.**");
            msg.Subject = "Pointer Security New Account Notification";
            msg.Body = x;
            gmail.Send(msg);


            db.SignalRMessageTable.Add(OBJM);
            db.SaveChanges();
            Clients.All.broadcastNotification(author, message);
        }
        private static string ResetPwdSendNotification(string ID)
        {
            PointerdbEntities db1 = new PointerdbEntities();
            try
            {

                 var password = GeneratePassword("8").ToString();
                 
                 PasswordHasher passwordsher = new PasswordHasher();
                 var pwdhashed = passwordsher.HashPassword(password);
               
                Tenant ObjTenant = db1.Tenant.Find(ID);
                AspNetUsers ObjAspnet = db1.AspNetUsers.Where(c => c.Email == ObjTenant.Username).FirstOrDefault();
                ObjAspnet.PasswordHash = pwdhashed;
                db1.AspNetUsers.Attach(ObjAspnet);
                var Entry = db1.Entry(ObjAspnet);
                Entry.Property(c=>c.PasswordHash).IsModified = true;
                db1.SaveChanges();

            if (ObjTenant!= null)
            {
                var aptNumber = db1.Apartment.Find(ObjTenant.aptID).ApartmentNumber;


                string string1 = "Hi " + ObjTenant.FirstName + " " + ObjTenant.LastName + ", your password has been reset by PointerWebApp.com ";
                string string2 = "The login information for apartment: " + aptNumber + " is below";
                string string3 = "Username: "******"Temporary password: "******"Click the on this http://localhost:64083/Account/Manage link and follow the instructions to initiate your account ";
                string string6 = "Company Description";
                string string7 = "Find more information...";

                string x = string.Format("{0}\n{1}\n{2}\n{3}\n{4}\n{5}\n{6}\n", string1, string2, string3, string4, string5, string6, string7);

                Gmail gmail = new Gmail("pointerwebapp", "Dmc10040!");
                MailMessage msg = new MailMessage("*****@*****.**", ObjTenant.Username);
                msg.Subject = "Pointer Security Password Reset Notification";
                msg.Body = x;
                gmail.Send(msg);
            }



            return "successful";

            }
            catch (Exception e)
            {
                throw e;
            }
        
        }
       public ActionResult RoleAddToUser(string UserName, string RoleName, string FirstName, string LastName, string Phone)
       {
          
            ApplicationDbContext context = new ApplicationDbContext();
            PointerdbEntities db = new PointerdbEntities();

            var UserManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(context));

            var CurrentUser = db.AspNetUsers.FirstOrDefault(c => c.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase));

            
            if (CurrentUser == null)
            {
                 ViewBag.Roles  = context.Roles.OrderBy(r => r.Name).ToList().Select(rr => new SelectListItem { Value = rr.Name.ToString(), Text = rr.Name }).ToList();
                
                ViewBag.clientlist = db.Clients.Select(c => new SelectListItem { Text = c.ClientName, Value = c.ID.ToString() }).ToList();
                ViewBag.ResultMessage = "There is no user with this Username !";
                return View("ManageUserRoles");
            }
            var currentUserID = CurrentUser.Id;
            var roleresult = UserManager.AddToRole(currentUserID, RoleName);
           
            ViewBag.ResultMessage = "Role created successfully !";

            var ObjisitManager = db.Manager.Find(currentUserID);
            Manager ObjManager = new Manager();
            if (ObjisitManager != null)
            {//update
                // ObjManager.ID = ObjisitManager.ID;
                //ObjManager.FirstName = ObjisitManager.FirstName;
                //ObjManager.LastName = ObjisitManager.LastName;
                //ObjManager.Phone = ObjisitManager.Phone;
                //db.Manager.Attach(ObjManager);
                //var Entry = db.Entry(ObjManager);
                //Entry.Property(c => c.FirstName).IsModified = true;
                //Entry.Property(c => c.LastName).IsModified = true;
                //Entry.Property(c => c.Phone).IsModified = true;
            }
            else 
            {//insert
                ObjManager.ID = currentUserID;
                ObjManager.FirstName = FirstName;
                ObjManager.LastName = LastName;
                ObjManager.Phone = Phone;
                db.Manager.Add(ObjManager);
                db.SaveChanges();
            }



           

           // prepopulat roles for the view dropdown
          ViewBag.Roles  = context.Roles.OrderBy(r => r.Name).ToList().Select(rr => new SelectListItem { Value = rr.Name.ToString(), Text = rr.Name }).ToList();
           ViewBag.clientlist = db.Clients.Select(c => new SelectListItem { Text = c.ClientName, Value = c.ID.ToString() }).ToList();
           return View("ManageUserRoles");
       }