public bool UpdateYourReview(TblTableReview tblTableReview)
        {
            TblTableReview tblTableReviewEntity = db.Set <TblTableReview>().Where(tto => tto.Id == tblTableReview.Id).FirstOrDefault();

            if (tblTableReviewEntity != null)
            {
                tblTableReviewEntity           = tblTableReview;
                tblTableReview.UpdatedDateTime = DateTime.Now;

                db.SaveChanges();

                return(true);
            }

            return(false);
        }
        /// <summary>
        /// Recording the customer rating the restaurants
        /// </summary>
        /// <param name="tblRating"></param>
        public int RestaurantRating(TblRating tblRating)
        {
            TblRating tr = db.TblRating.Where(r => r.TblRestaurantId == tblRating.TblRestaurantId && r.TblCustomerId == tblRating.TblCustomerId).FirstOrDefault();

            if (tr != null)
            {
                tr.Comments               = tblRating.Comments;
                tr.Rating                 = tblRating.Rating;
                tr.RecordTimeStamp        = DateTime.Now;
                tr.RecordTimeStampCreated = DateTime.Now;
                tr.TblCustomerId          = tblRating.TblCustomerId;
                tr.TblRestaurantId        = tblRating.TblRestaurantId;
                db.SaveChanges();
                return(tr.Id);
            }
            else
            {
                db.Set <TblRating>().Add(tblRating);
                db.SaveChanges();
                return(tblRating.Id);
            }
        }
 public IQueryable <TblRating> RestaurantReviewRating(ReviewRating reviewRating)
 {
     try
     {
         if (dbContext != null)
         {
             TblRating tblRating = new TblRating
             {
                 Rating                 = reviewRating.Rating,
                 Comments               = reviewRating.ReviewComments,
                 TblRestaurantId        = reviewRating.RestaurantID,
                 TblCustomerId          = reviewRating.CustomerId,
                 RecordTimeStamp        = DateTime.Now,
                 RecordTimeStampCreated = DateTime.Now
             };
             dbContext.Set <TblRating>().Add(tblRating);
             dbContext.SaveChanges();
             return((from rating in dbContext.TblRating
                     join restaurant in dbContext.TblRestaurant on
                     rating.TblRestaurantId equals restaurant.Id
                     where rating.TblRestaurantId == reviewRating.RestaurantID && rating.TblCustomerId == reviewRating.CustomerId
                     select new TblRating
             {
                 Rating = rating.Rating,
                 Comments = rating.Comments,
                 TblRestaurantId = restaurant.Id,
                 TblRestaurant = restaurant,
                 TblCustomerId = rating.TblCustomerId
             }).AsQueryable());
         }
         return(null);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }