Esempio n. 1
0
        public async Task <PartialViewResult> Vote(bool theUpVote, int?id, int channelID, string userName)
        {
            if (id == null)
            {
                return(PartialView());
            }
            ChannelVote solutionVote = await db.ChannelVotes.FindAsync(channelID);

            if (solutionVote == null)
            {
                solutionVote = new ChannelVote();
                solutionVote.CreationDate = DateTime.Now;
                solutionVote.Channel      = await db.Channels.FindAsync(channelID);

                solutionVote.ChannelID = channelID;
                solutionVote.UserID    = userName;
            }
            else
            {
                solutionVote.upVote          = theUpVote;
                db.Entry(solutionVote).State = EntityState.Modified;
            }
            await db.SaveChangesAsync();

            return(PartialView(solutionVote));
        }
Esempio n. 2
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            ChannelVote channelVote = await db.ChannelVotes.FindAsync(id);

            db.ChannelVotes.Remove(channelVote);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
        public async Task <ActionResult> Edit([Bind(Include = "VoteID,UserID,upVote,ChannelID")] ChannelVote channelVote)
        {
            if (ModelState.IsValid)
            {
                db.Entry(channelVote).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            ViewBag.ChannelID = new SelectList(db.Channels, "ChannelID", "Title", channelVote.ChannelID);
            return(View(channelVote));
        }
Esempio n. 4
0
        public async Task <ActionResult> Create([Bind(Include = "VoteID,UserID,upVote,ChannelID")] ChannelVote channelVote)
        {
            if (ModelState.IsValid)
            {
                channelVote.CreationDate = DateTime.Now;
                db.ChannelVotes.Add(channelVote);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ChannelID = new SelectList(db.Channels, "ChannelID", "Title", channelVote.ChannelID);
            return(View(channelVote));
        }
Esempio n. 5
0
        // GET: ChannelVotes/Details/5
        public async Task <ActionResult> Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChannelVote channelVote = await db.ChannelVotes.FindAsync(id);

            if (channelVote == null)
            {
                return(HttpNotFound());
            }
            return(View(channelVote));
        }
Esempio n. 6
0
        // GET: ChannelVotes/Edit/5
        public async Task <ActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ChannelVote channelVote = await db.ChannelVotes.FindAsync(id);

            if (channelVote == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ChannelID = new SelectList(db.Channels, "ChannelID", "Title", channelVote.ChannelID);
            return(View(channelVote));
        }