예제 #1
0
        public ActionResult Competition(int competitionID)
        {
            var competition = CompetitionService.GetByPK(competitionID);

            return(View(ViewNames.Competition,
                        new CompetitionVM {
                Competition = competition,
                IsJoin = competition.UserCompetitions.Any(uc => uc.UserID == User.UserID),
                IsWinner = competition.WinnerID == User.UserID,
            }));
        }
예제 #2
0
        public ActionResult Competition(CompetitionVM model)
        {
            model.UploadFile = UserFiles.GetUploadFile(Request.Files[0]);

            if (FluentValidate(model))
            {
                var competition =
                    model.Competition
                    = CompetitionService.GetByPK(model.Competition.CompetitionID);
                if (competition.UserCompetitions.All(uc => uc.UserID != User.UserID))
                {
                    competition.UserCompetitions.Add(
                        new UserCompetition {
                        UserID = User.UserID
                    });
                }
                CompetitionService.SubmitChanges();
                MailService.SendCompetitionRequest(model);
            }
            return(RedirectBack());
        }