Пример #1
0
        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));
        }
Пример #2
0
        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));
        }
Пример #3
0
        public IHttpActionResult GetRiderReview(int id)
        {
            RiderReview riderReview = db.RiderReviews.Find(id);

            if (riderReview == null)
            {
                return(NotFound());
            }

            return(Ok(riderReview));
        }
Пример #4
0
 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
     });
 }
Пример #5
0
        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));
        }
Пример #6
0
        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);
        }