コード例 #1
0
ファイル: RoundController.cs プロジェクト: ivokst92/BetINK
        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)));
        }
コード例 #2
0
ファイル: RoundController.cs プロジェクト: ivokst92/BetINK
        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)));
        }
コード例 #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 }));
        }
コード例 #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 }));
        }