Ejemplo n.º 1
0
        public ActionResult Index()
        {
            var     client = new FacebookWebClient();
            dynamic me     = client.Get("me");

            ViewBag.Name = me.name;
            ViewBag.Id   = me.id.ToString();

            JokesFeedViewModel model = new JokesFeedViewModel();

            model.UserName = me.name;
            model.UserId   = me.id;
            IJokesRepository jokeRep  = new JokesRepository();
            IVotesRepository votesRep = new VotesRepository();
            List <Jokes>     allJokes = jokeRep.GetAllJokesByDate().ToList <Jokes>();

            if (allJokes != null)
            {
                foreach (Jokes joke in allJokes)
                {
                    joke.UserVoteType   = votesRep.GetCurrentUserVote(joke.JokeId, joke.UserId);
                    joke.UpVotesCount   = votesRep.GetJokesVotesCount(joke.JokeId, true);
                    joke.DownVotesCount = votesRep.GetJokesVotesCount(joke.JokeId, false);
                    dynamic jUser = client.Get(joke.UserId.ToString());
                    joke.UserName = jUser.name;
                }
                model.Jokes = allJokes;
            }

            return(View(model));
        }
Ejemplo n.º 2
0
        public ActionResult Vote(VoteVM voteModel)
        {
            VotesRepository votesRepo = new VotesRepository();

            votesRepo.Vote(Models.AuthManager.LoggedUser.Id, voteModel.ContentId, voteModel.Value, voteModel.Type);

            return(Redirect(Request.UrlReferrer.ToString()));
        }
Ejemplo n.º 3
0
        public string VoteToJoke(long pUserId, int pJokeId, bool pVoteType)
        {
            IVotesRepository votesRep = new VotesRepository();

            if (votesRep.AddVote(pJokeId, pUserId, pVoteType))
            {
                return("Success");
            }
            else
            {
                return("Failure");
            }
        }
Ejemplo n.º 4
0
 public UnitOfWork(WebStoreContext context)
 {
     this.context   = context;
     Products       = new ProductsRepository(context);
     Sliders        = new SlidersRepository(context);
     FooterMenus    = new FooterMenusRepository(context);
     HeadingMenus   = new HeadingMenusRepository(context);
     Polls          = new PollsRepository(context);
     Prices         = new PricesRepository(context);
     ProductVariant = new ProductVariantsRepository(context);
     Colors         = new ColorsRepository(context);
     Votes          = new VotesRepository(context);
     Options        = new OptionsRepository(context);
     Ratings        = new RatingsRepository(context);
     Ordered        = new OrderedRepository(context);
     Orders         = new OrdersRepository(context);
 }