public IActionResult ChangeStatus(ChangeStatusViewModel model) { if (ModelState.IsValid) { User user = _context.FindUser(model.Id); if (user != null) { bool result; if (model.StatusName == "block") { if (model.IsForever == true) //заблокировать навсегда { user.id_status = _context.FindStatus(model.StatusName).Id; result = _context.BlockUserForever(user.Id, user); } else //заблокировать до времени { user.id_status = _context.FindStatus(model.StatusName).Id; user.dateofbeginblock = DateTime.Now; user.dateofendbock = model.Dateofendblock; result = _context.BlockUser(user.Id, user); } } else //notblock { user.id_status = _context.FindStatus(model.StatusName).Id; result = _context.UnblockUser(user.Id, user); } if (result) { return(RedirectToAction("Index")); } else { ModelState.AddModelError(string.Empty, "Ошибка"); } } } else { ModelState.AddModelError("", "Ошибка"); } return(View(model)); }