Exemplo n.º 1
0
        public IActionResult EditRound(int Id, RoundFormViewModel model)
        {
            bool allowedToEdit = this.roundService
                                 .IsUserAllowedToEdit(Id, User.Identity.Name);

            if (!allowedToEdit)
            {
                TempData.AddErrorMessage(MessageResources.msgNotAllowedToEditRound);
                return(RedirectToAction(nameof(All)));
            }

            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            this.roundService.Edit(Id,
                                   model.Number,
                                   model.Description,
                                   User.Identity.Name);

            this.TempData.AddSuccessMessage(MessageResources.msgSuccessfullyEdited);

            return(RedirectToAction(nameof(All)));
        }
Exemplo n.º 2
0
        public IActionResult AddRound(RoundFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            this.roundService.Create(model.Number,
                                     model.Description,
                                     User.Identity.Name);

            return(RedirectToAction(nameof(All)));
        }
Exemplo n.º 3
0
        public IActionResult AddRound(RoundFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var seasonId = Int32.Parse(TempData[SeasonId].ToString());

            this.roundService.Create(seasonId,
                                     model.Number,
                                     model.Description,
                                     User.Identity.Name);

            this.TempData.AddSuccessMessage(MessageResources.msgSuccessfullyAdded);

            return(RedirectToAction(nameof(All), new { seasonId = seasonId }));
        }
Exemplo n.º 4
0
        public IActionResult EditRound(int roundId, RoundFormViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            int seasonId = this.roundService.Edit(roundId,
                                                  model.Number,
                                                  model.Description,
                                                  User.Identity.Name);

            if (seasonId == default(int))
            {
                return(BadRequest());
            }

            this.TempData.AddSuccessMessage(MessageResources.msgSuccessfullyEdited);
            return(RedirectToAction(nameof(All), new { seasonId = seasonId }));
        }