public ActionResult PanelControl()
 {
     using (ApplicationDbContext ctx = new ApplicationDbContext())
     {
         BanControlModels model = new BanControlModels();
         model.Ban = new BansList();
         return(View(model));
     }
 }
        public ActionResult PanelControl(BanControlModels model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            ApplicationUser user = null;

            if (model.IdOrEmail.Contains("@"))
            {
                user = UserManager.FindByEmail(model.IdOrEmail);
            }
            else
            {
                user = UserManager.FindById(model.IdOrEmail);
            }

            if (model.BanOrUnban == false)
            {
                UserManager.FindById(user.Id).Ban = null;
                UserManager.RemoveFromRole(user.Id, "Banned");
                UserManager.AddToRole(user.Id, "User");
                UserManager.SendEmail(user.Id, "Your account has been unbanned. Time:  " + DateTime.Now, $"Hello {user.UserName} Your account has been unbanned!!!");
                BanControlModels models = new BanControlModels();
                models.Ban = new BansList();
                return(View(models));
            }
            else
            {
                if (model.Ban.IsPermanent)
                {
                    UserManager.FindById(user.Id).Ban = new BansList()
                    {
                        IsPermanent = true, Reason = model.Ban.Reason, DateBan = DateTime.Now, ToDate = DateTime.Now.AddYears(120)
                    };
                    UserManager.RemoveFromRole(user.Id, "User");
                    UserManager.AddToRole(user.Id, "Banned");
                    UserManager.SendEmail(user.Id, "Your account has been banned. Time:  " + DateTime.Now, $"Hello {user.UserName} Your account has been banned!!!");
                }
                else
                {
                    UserManager.FindById(user.Id).Ban = new BansList()
                    {
                        IsPermanent = false, ToDate = DateTime.Now.AddHours(model.CountHour), Reason = model.Ban.Reason, DateBan = DateTime.Now
                    };
                    UserManager.RemoveFromRole(user.Id, "User");
                    UserManager.AddToRole(user.Id, "Banned");
                    UserManager.SendEmail(user.Id, "Your account has been banned. Time:  " + DateTime.Now, $"Hello {user.UserName} Your account has been banned!!!");
                }
                BanControlModels models = new BanControlModels();
                models.Ban = new BansList();
                return(View(models));
            }
        }