Exemple #1
0
        public async Task LeaveFeedback()
        {
            var request = new RatingUpsertRequest
            {
                Description  = Description,
                RatingTypeId = SelectedRatingType.RatingTypeId,
                RequestId    = Id,
                SupplierId   = SupplierId
            };

            var rating = await _ratingService.Insert <Rating>(request);

            var notificationRequest = new NotificationInsertRequest
            {
                CreatedAt          = DateTime.Now,
                ItemId             = rating.RatingId,
                NotificationTypeId = (int)NotificationType.Feedback,
                UserFromId         = ClientId,
                UserToId           = SupplierId
            };

            await _notificationService.Insert <Model.Notification>(notificationRequest);

            await Init();
        }
Exemple #2
0
        public Data.Model.Rating InsertRatingByUser(RatingUpsertRequest request)
        {
            var x = _context.Rating.Where(x => x.AppUserId == request.AppUserId && x.MovieAndTvshowId == request.MovieAndTvshowId).SingleOrDefault();

            if (x != null)
            {
                x.RatingValue = request.RatingValue;
                _context.SaveChanges();
                return(_mapper.Map <Data.Model.Rating>(x));
            }
            else
            {
                var entity = _mapper.Map <Database.Rating>(request);
                _context.Rating.Add(entity);
                _context.MovieAndTvshow.Where(x => x.Id == request.MovieAndTvshowId).SingleOrDefault().NumberOfRatings++;
                _context.SaveChanges();
                return(_mapper.Map <Data.Model.Rating>(entity));
            }
        }
 public Data.Model.Rating InsertRatingByUser(RatingUpsertRequest request)
 {
     return(_service.InsertRatingByUser(request));
 }