Example #1
0
        public void Create(PlaceReviewEditModel model)
        {
            var placeId = placeService.GetPlaceId(model.Place);

            placeTypeService.CreatePlaceTypesForPlace(placeId, model.Place.GTypes);

            int?imageId = null;

            if (!string.IsNullOrEmpty(model.ImageUri))
            {
                imageId = imageService.CreateImage(model.ImageUri);
            }

            var review = new Review
            {
                Text            = model.Review,
                Rating          = model.Rating,
                CreatedByUserId = UserHelper.GetCurrentUserId(),
                CreatedDateTime = DateTime.Now,
                PlaceId         = placeId,
                IsValid         = true,
                ImageId         = imageId
            };

            reviewRepository.Insert(review);

            var placeReview = new PlaceReview
            {
                ReviewId = review.Id
            };

            placeReviewRepository.Insert(placeReview);

            model.Id = placeReview.Id;
        }
Example #2
0
        public void Create(DishReviewEditModel model)
        {
            int dishId  = model.DishId ?? 0;
            int placeId = placeService.GetPlaceId(model.Place);

            placeTypeService.CreatePlaceTypesForPlace(placeId, model.Place.GTypes);

            if (!model.DishId.HasValue)
            {
                var newDish = new Dish
                {
                    CreatedByUserId = UserHelper.GetCurrentUserId(),
                    CreatedDateTime = DateTime.Now,
                    Name            = model.DishName,
                    IsConfirmed     = false,
                    IsValid         = true
                };

                dishRepository.Insert(newDish);

                dishId = newDish.Id;
            }

            int?imageId = null;

            if (!string.IsNullOrEmpty(model.ImageUri))
            {
                imageId = imageService.CreateImage(model.ImageUri);
            }

            var review = new Review
            {
                CreatedByUserId = UserHelper.GetCurrentUserId(),
                CreatedDateTime = DateTime.Now,
                Text            = model.Review,
                PlaceId         = placeId,
                IsValid         = true,
                Rating          = model.Rating,
                ImageId         = imageId
            };

            reviewRepository.Insert(review);

            var dishReview = new DishReview
            {
                DishId   = dishId,
                ReviewId = review.Id
            };

            dishService.CreateDishTags(model.TagIdList, dishId);

            dishReviewRepository.Insert(dishReview);
        }