Exemple #1
0
        public BaseResponse <RestaurantCounters> IncreaseTotalNotRecommendeds(int restaurantFid)
        {
            var topupModel = new RestaurantCounterTopupModel()
            {
                RestaurantFid        = restaurantFid,
                TotalNotRecommendeds = 1
            };

            return(TopupCounter(topupModel));
        }
Exemple #2
0
        public BaseResponse <RestaurantCounters> IncreaseTotalSuccessReservations(int restaurantFid)
        {
            var topupModel = new RestaurantCounterTopupModel()
            {
                RestaurantFid            = restaurantFid,
                TotalSuccessReservations = 1
            };

            return(TopupCounter(topupModel));
        }
Exemple #3
0
        public BaseResponse <RestaurantCounters> TopupCounter(RestaurantCounterTopupModel topupModel)
        {
            try
            {
                if (topupModel == null)
                {
                    return(BaseResponse <RestaurantCounters> .NotFound());
                }
                var counterDb = _searchContext.RestaurantCounters.Where(k => k.RestaurantId == topupModel.RestaurantFid).FirstOrDefault();

                if (counterDb == null)
                {
                    return(BaseResponse <RestaurantCounters> .NotFound());
                }

                if (topupModel.TotalViews > 0)
                {
                    counterDb.TotalViews += topupModel.TotalViews;
                }
                if (topupModel.TotalReservations > 0)
                {
                    counterDb.TotalReservations += topupModel.TotalReservations;
                }
                if (topupModel.TotalSuccessReservations > 0)
                {
                    counterDb.TotalSuccessReservations += topupModel.TotalSuccessReservations;
                }
                if (topupModel.TotalReviews > 0)
                {
                    counterDb.TotalReviews += topupModel.TotalReviews;
                }
                if (topupModel.TotalRecommendeds > 0)
                {
                    counterDb.TotalRecommendeds += topupModel.TotalRecommendeds;
                }
                if (topupModel.TotalNotRecommendeds > 0)
                {
                    counterDb.TotalNotRecommendeds += topupModel.TotalNotRecommendeds;
                }

                var result = _searchContext.SaveChanges();
                if (result != 1)
                {
                    return(BaseResponse <RestaurantCounters> .InternalServerError());
                }

                return(BaseResponse <RestaurantCounters> .Success(counterDb));
            }
            catch (Exception ex)
            {
                return(BaseResponse <RestaurantCounters> .InternalServerError(message : ex.Message, fullMsg : ex.StackTrace));
            }
        }