public IHttpActionResult PostRiderReview(RiderReview riderReview) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.RiderReviews.Add(riderReview); try { db.SaveChanges(); } catch (DbUpdateException) { if (RiderReviewExists(riderReview.ID)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = riderReview.ID }, riderReview)); }
public IHttpActionResult PutRiderReview(int id, RiderReview riderReview) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != riderReview.ID) { return(BadRequest()); } db.Entry(riderReview).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RiderReviewExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult GetRiderReview(int id) { RiderReview riderReview = db.RiderReviews.Find(id); if (riderReview == null) { return(NotFound()); } return(Ok(riderReview)); }
private RiderReviewDto ToRiderReviewDto(RiderReview rw) { return(new RiderReviewDto { IdOrder = rw.IdOrder, IdRider = rw.IdRyder, IdUser = rw.IdUser, Rating = rw.Rating, Review = rw.Review, RiderName = rw.RyderName, UserName = rw.UserName }); }
public IHttpActionResult DeleteRiderReview(int id) { RiderReview riderReview = db.RiderReviews.Find(id); if (riderReview == null) { return(NotFound()); } db.RiderReviews.Remove(riderReview); db.SaveChanges(); return(Ok(riderReview)); }
public async Task AddRiderReview(RiderReviewDto riderReviewDto) { var ryderReview = new RiderReview { IdOrder = riderReviewDto.IdOrder, UserName = riderReviewDto.UserName, Review = riderReviewDto.Review, Rating = riderReviewDto.Rating, IdUser = riderReviewDto.IdUser, IdRyder = riderReviewDto.IdRider, RyderName = riderReviewDto.RyderName, }; await this.reviewsDBContext.RidersReviews.AddAsync(ryderReview); this.reviewEventsManager.RiderRatingChanged(riderReviewDto.IdRider, riderReviewDto.Rating); }