Example #1
0
        public ActionResult Candidate(int partyID)
        {
            var party  = partyRepository.GetById(partyID);
            var entity = SessionHelper.CurrentEntity;

            if (entity.EntityTypeID != (int)EntityTypeEnum.Citizen)
            {
                AddError("Only citizens can candidate!");
                return(RedirectToAction("View", new { partyID = partyID }));
            }

            var errorMessage = partyService.CanCandidate(party, entity.Citizen);

            if (string.IsNullOrEmpty(errorMessage))
            {
                partyService.Candidate(party, entity.Citizen.PartyMember);

                AddInfo("You are a candidate for upcoming party elections");
                return(RedirectToAction("View", new { partyID = partyID }));
            }

            AddError(errorMessage);
            return(RedirectToAction("View", new { partyID = partyID }));
        }