コード例 #1
0
 public void Create(User newUser)
 {
     // if(!_db.Users.Any( a => a.Username == newUser.Username))
     // {
     _db.Users.Add(newUser);
     _db.SaveChanges();
     // }
 }
コード例 #2
0
        public void Post([FromBody] Question newQuestion)
        {
            var identity = (ClaimsIdentity)User.Identity;
            var foundId  = identity.FindFirst(ClaimTypes.Name).Value;

            newQuestion.UserID = Convert.ToInt32(foundId);
            _db.Questions.Add(newQuestion);
            _db.SaveChanges();
        }
コード例 #3
0
        public void Post([FromBody] Answer newAnswer, int id)
        {
            var identity = (ClaimsIdentity)User.Identity;
            var foundId  = identity.FindFirst(ClaimTypes.Name).Value;

            newAnswer.UserId     = Convert.ToInt32(foundId);
            newAnswer.QuestionID = id;

            _db.Answers.Add(newAnswer);
            _db.SaveChanges();
        }
コード例 #4
0
 public void Post([FromBody] User newUser)
 {
     _db.Users.Add(newUser);
     _db.SaveChanges();
 }