示例#1
0
        public ActionResult PostIdea(Idea idea)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            idea.Time = DateTime.Now;
            dbc.Idea.Add(idea);

            dbc.SaveChanges();

            return(Ok(idea));
        }
示例#2
0
        public ActionResult PostComment(Comment comment)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var vote = dbc.Idea.Where(i => i.IdeaId == comment.IdeaId).FirstOrDefault();

            vote.Votecounter += comment.Procon;
            dbc.Comment.Add(comment);
            dbc.SaveChanges();

            return(Ok(comment));
        }
示例#3
0
        public ActionResult <Ideaspace> PostIdeaSpace(Ideaspace ideaspace)
        {
            //Ideaspace ideaspace = new Ideaspace { Name = name, Password = password, Description = description };
            var q = dbc.Ideaspace.Where(i => i.Name == ideaspace.Name).FirstOrDefault();

            if (q != null)
            {
                return(Unauthorized());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            byte[] salt = new byte[16];

            ideaspace.Password     = Convert.ToBase64String(Hash(ideaspace.Password, salt));
            ideaspace.PasswordSalt = Convert.ToBase64String(salt);

            dbc.Ideaspace.Add(ideaspace);
            dbc.SaveChanges();

            return(Ok(ideaspace));
        }