コード例 #1
0
 // POST /api/reviews
 public HttpResponseMessage Post(ReviewRequestModel model)
 {
     if (ModelState.IsValid)
     {
         Review r = Reviews.CreateReview(model.Title, model.Description, User.Identity.UserId);
         return Created(new
         {
             Id = r.Id,
             Href = Url.Resource(r)
         });
     }
     return ValidationErrors();
 }
コード例 #2
0
ファイル: ReviewsController.cs プロジェクト: anurse/ReviewR
 // POST /api/reviews
 public HttpResponseMessage Post(ReviewRequestModel model)
 {
     Requires.NotNull(model, "model");
     if (ModelState.IsValid)
     {
         Review r = Reviews.CreateReview(model.Title, model.Description, User.Identity.UserId);
         return Created(new ReviewModel()
         {
             Id = r.Id,
             Title = r.Name,
             Author = UserModel.FromUser(User)
         });
     }
     return ValidationErrors();
 }