Exemplo n.º 1
0
        public ActionResult AdminIndex()
        {
            BusinessLayer bal = new BusinessLayer();

            User currentLogged = bal.GetUserByUsername(User.Identity.Name);

            if (bal.IsUserAlreadyVoted(currentLogged.UserID))
            {
                VoteListViewModel vlvm = new VoteListViewModel();
                vlvm.VoteViewModels = this.GetVoteViewModel(bal.GetVotes());
                return(View("VotingResultsAdmin", vlvm));
            }
            int                  userID       = bal.GetBirthdayUserID();
            User                 birthdayUser = bal.GetUserById(userID);
            UserViewModel        uvm          = new UserViewModel(birthdayUser.UserID, birthdayUser.Username, birthdayUser.Birthdate);
            PresentListViewModel plvm         = new PresentListViewModel();

            plvm.Presents = this.GetPresentsViewModel(bal.GetPresents());
            VotingUserViewModel vvm = new VotingUserViewModel();

            vvm.User     = uvm;
            vvm.Presents = plvm;

            //bal.InitializeVoting(currentLogged.UserID, birthdayUser.UserID);

            return(View("IndexAdmin", vvm));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            BusinessLayer bal = new BusinessLayer();

            int userID = Convert.ToInt32(Request.Form["submit"]);

            User                 birthdayUser  = bal.GetUserById(userID);
            User                 currentLogged = bal.GetUserByUsername(User.Identity.Name);
            UserViewModel        uvm           = new UserViewModel(birthdayUser.UserID, birthdayUser.Username, birthdayUser.Birthdate);
            PresentListViewModel plvm          = new PresentListViewModel();

            plvm.Presents = this.GetPresentsViewModel(bal.GetPresents());
            VotingUserViewModel vvm = new VotingUserViewModel();

            vvm.User     = uvm;
            vvm.Presents = plvm;

            bal.InitializeVoting(currentLogged.UserID, birthdayUser.UserID);

            return(View("Index", vvm));
        }