Пример #1
0
 public ActionResult SignUp(ParticipancySignUpViewModel model)
 {
     if (ModelState.IsValid)
     {
         var userId        = _userManager.GetUserId(HttpContext.User);
         var currentSeason = _seasonRepository.GetCurrentSeason();
         if (currentSeason == null)
         {
             StatusMessage = "Error. Signing up is forbidden for now.";
             return(RedirectToAction("MyParticipancies"));
         }
         if (_participanciesRepository.GetUserCurrentParticipancy(userId) != null)
         {
             StatusMessage = "Error. You are already signed up!.";
             return(RedirectToAction("MyParticipancies"));
         }
         var participancy = Mapper.Map <ParticipancyDTO>(model);
         participancy.UserId   = userId;
         participancy.SeasonId = currentSeason.Id;
         var result = _participanciesRepository.AddParticipancy(participancy);
         if (result == 1)
         {
             StatusMessage = "Succesfully signed.";
             return(RedirectToAction(nameof(MyParticipancies)));
         }
     }
     model.StatusMessage = "Error. Entered data is not valid.";
     return(View(model));
 }
Пример #2
0
        public ActionResult SignUp()
        {
            var userId        = _userManager.GetUserId(HttpContext.User);
            var currentSeason = _seasonRepository.GetCurrentSeason();

            if (currentSeason == null)
            {
                StatusMessage = "Error. Signing up is forbidden for now.";
                return(RedirectToAction("MyParticipancies"));
            }
            if (_participanciesRepository.GetUserCurrentParticipancy(userId) != null)
            {
                StatusMessage = "Error. You are already signed up!.";
                return(RedirectToAction("MyParticipancies"));
            }
            var model = new ParticipancySignUpViewModel()
            {
                SeasonName    = currentSeason.Name + " " + currentSeason.EditionNumber,
                StatusMessage = StatusMessage,
                Deadline      = currentSeason.EndDate
            };

            return(View(model));
        }