Ejemplo n.º 1
0
        public ActionResult _BanList()
        {
            BanViewModel banModel = new BanViewModel();

            banModel.listModel = _banService.GetBan().Select(x => new ItemBanViewModel
            {
                ID = x.ID,
                Description = x.Description,
                FinishDate = x.Finish_Date,
                StartDate = x.Start_Date,
                User_Login = x.Login
            }).ToList();

            banModel.allUser = _userService.GetUser().Select(x => x.Login).ToArray();

            return View(banModel);
        }
Ejemplo n.º 2
0
        public ActionResult AddBan(BanViewModel banModel)
        {
            List<string> errors;
            if (Session["val"] != null)
            {
                errors = ((string[])Session["val"]).ToList();
            }
            else
            {
                errors = new List<string>();
            }

            BanDto _banDto = new BanDto();

            _banDto.Login = banModel.viewModel.User_Login;
            _banDto.Description = banModel.viewModel.Description;
            _banDto.Finish_Date = banModel.viewModel.FinishDate;

            if (_banService.Add(_banDto))
            {
                errors.Add("Zablokowano gracza.");
            }
            else
            {
                errors.Add("Błąd. Srpróbuj ponownie.");
            }
            Session["val"] = errors.ToArray<string>();

            return RedirectToAction("Admin");
        }