示例#1
0
        public ActionResult _Register2(int topicID, int voterID, VoteKind vote, VoteLinkLevel linkLevel)
        {
            if (db.Topics.Find(topicID).IsReadOnly)
                return HTTPStatus(HttpStatusCode.Forbidden, "Das Thema ist schreibgeschützt.");

            if (IsTopicLocked(topicID))
                return HTTPStatus(HttpStatusCode.Forbidden, "Das Thema ist gesperrt.");

            User voter = db.Users.Find(voterID);
            db.Votes.Single(v => v.Voter.ID == voter.ID && v.Topic.ID == topicID).Kind = vote;

            string message = string.Format("{0} hat in Vertretung für {1} abgestimmt mit \"{2}\".", GetCurrentUser().ShortName,
                voter.ShortName,
                vote.DisplayName());

            db.Comments.Add(new Comment {Author = db.Users.Find(voterID), TopicID = topicID, Content = message});
            db.SaveChanges();
            return _List(db.Topics.Find(topicID), linkLevel);
        }