コード例 #1
0
        public IHttpActionResult stemAntwoord(ANDROIDstem aStem)
        {
            Antwoord antwoord = antwoordManager.readAllAntwoorden().Find(o => o.ID == aStem.antwoordid);

            foreach (var stem in antwoord.stemmen)
            {
                if (stem.gebruikersNaam == aStem.gebruikersNaam)
                {
                    return(Ok("nok"));
                }
                else
                {
                    break;
                }
            }

            Stem stemAntwoord = new Stem()
            {
                antwoord       = antwoordManager.readAntwoord(aStem.antwoordid),
                gebruikersNaam = aStem.gebruikersNaam
            };

            stemManager.stemOpAntwoord(stemAntwoord);
            return(Ok("ok"));
        }
コード例 #2
0
        public ActionResult VoteUp(int id)
        {
            if (Request.IsAuthenticated)
            {
                Stem stem = null;

                DossierAntwoord dossierAntwoord = antwManager.readDossierAntwoord(id);
                if (dossierAntwoord.stemmen == null || dossierAntwoord.stemmen.Count == 0)
                {
                    dossierAntwoord.stemmen = new List <Stem>();
                }
                else
                {
                    stem = dossierAntwoord.stemmen.FirstOrDefault(stemx => stemx.gebruikersNaam == User.Identity.GetUserName());
                }



                if (stem == null)
                {
                    Stem nieuwLike = new Stem()
                    {
                        gebruikersNaam = User.Identity.GetUserName(),
                        antwoord       = dossierAntwoord
                    };

                    stemManager.stemOpAntwoord(nieuwLike);

                    return(RedirectToAction("Dossier", "Module"));
                }
                else
                {
                    return(RedirectToAction("StemError", "Stem"));
                }
            }
            else
            {
                return(RedirectToAction("Login", "Account"));
            }
        }