Esempio n. 1
0
        public IActionResult Block(int unit, BlockingViewModel model, string blocking)
        {
            setDbContext();
            model.BeginningDate = DateTime.Now;
            if (blocking == "permanently")
            {
                model.Permanently = true;
            }
            else
            {
                model.Permanently = false;
                switch (blocking)
                {
                case "hours":
                    model.ExpirationDate = DateTime.Now.AddHours(unit);
                    break;

                case "days":
                    model.ExpirationDate = DateTime.Now.AddDays(unit);
                    break;

                case "months":
                    model.ExpirationDate = DateTime.Now.AddMonths(unit);
                    break;

                case "years":
                    model.ExpirationDate = DateTime.Now.AddYears(unit);
                    break;
                }
            }
            context.BlockUser(model);
            return(RedirectToAction("Index", "Clients"));
        }