Пример #1
0
 public async Task<IHttpActionResult> AddReview(Review review)
 {
     if (User.Identity.IsAuthenticated)
     {
         review.reviewedBy = User.Identity.GetUserId();
         review.time = DateTime.UtcNow;
         db.Reviews.Add(review);
         await db.SaveChangesAsync();
         var ret =await (from rev in db.Reviews
                   where rev.Id.Equals(review.Id)
                   select new
                   {
                       id = rev.Id,
                       reviewDescription = rev.description,
                       reviewedBy = rev.reviewedBy,
                       reviewedByName = rev.AspNetUser.Email,
                       time = rev.time,
                       rating = rev.rating,
                   }).FirstOrDefaultAsync();
         return Ok(ret);
     }
     return BadRequest();
 }
Пример #2
0
 public async Task<IHttpActionResult> UpdateReview(Review review)
 {
     if (User.Identity.IsAuthenticated)
     {
         if (!ModelState.IsValid)
         {
             return BadRequest();
         }
         db.Entry(review).State = EntityState.Modified;
         await db.SaveChangesAsync();
         return Ok("Done");
     }
     return BadRequest();
 }