Inheritance: ItemWithScreen
        public FeedbackSummary(Feedback feedback)
            : base(feedback)
        {
            this.Ratings = new List<RatingAggregate>();
            this.Ratings.Add(new RatingAggregate(feedback.ScreenName,
                (int)feedback.Rating));

            this.SumOfRatings += (int)feedback.Rating;
        }
        public void Save_RawRecord_Saves()
        {
            FeedbackMapper feedbackMapper = new FeedbackMapper(this.client, this.database);
            Guid applicationId = Guid.NewGuid();
            Guid deviceId = Guid.NewGuid();

            Feedback feedback = new Feedback()
                {
                    ApplicationId = applicationId,
                    DeviceId = deviceId,
                    Message = "feedback",
                    Rating =  FeedbackRatingType.Five,
                    ScreenName =  "screenName",
                    SessionId = Guid.NewGuid(),
                    DateCreatedOnDevice =  DateTime.Now,
                    Version = "1.1"
                };

            feedbackMapper.Save(feedback);
        }
 public void Save(Feedback entity)
 {
     base.Save(entity);
 }
        public void Log(Feedback feedbackItem)
        {
            Application application = this.applicationRepository.Find(feedbackItem.ApplicationId);

            if (application != null)
            {
                DeviceInfo device = this.deviceRepository.Find(feedbackItem.DeviceId);

                if (device != null)
                {
                    feedbackItem.PlatformId = device.PlatformType;

                    FeedbackSummary feedbackSum = new FeedbackSummary(feedbackItem);

                    this.feedbackRepository.Save(feedbackSum);
                    this.feedbackRepository.Save(feedbackItem);
                }
                else
                {
                    throw new NoDeviceException(feedbackItem.DeviceId);
                }
            }
            else
            {
                throw new InactiveApplicationException(feedbackItem.ApplicationId);
            }
        }
 public void Save(Feedback entity)
 {
     this.feedbackMapper.Save(entity);
 }
        public void Save_SummaryRecord_MatchesSummary()
        {
            FeedbackMapper feedbackMapper = new FeedbackMapper(this.client, this.database);
            Guid applicationId = Guid.NewGuid();
            string screenName = "screenName";

            FeedbackSummary expected = new FeedbackSummary()
            {
                ApplicationId = applicationId,
                Count = 2,
                Date = date,
                PlatformId = platform,
                Ratings = new List<RatingAggregate>()
                {
                     new RatingAggregate(screenName, 8)
                     {
                         Count = 2
                     }
                },
                Version = version,
                SumOfRatings = 8
            };

            Feedback feedback = new Feedback()
                {
                    ApplicationId = applicationId,
                    DeviceId = Guid.NewGuid(),
                    Message = "feedback",
                    Rating =  FeedbackRatingType.Five,
                    ScreenName =  screenName,
                    SessionId = Guid.NewGuid(),
                    DateCreatedOnDevice =  dateCreatedOnDevice,
                    Date = date,
                    DateCreated = DateTime.Now,
                    Version = version,
                    PlatformId = platform
                };

            FeedbackSummary summary = new FeedbackSummary(feedback);
            feedbackMapper.Save(summary);

            Feedback feedback2 = new Feedback()
            {
                ApplicationId = applicationId,
                DeviceId = Guid.NewGuid(),
                Message = "feedback",
                Rating =  FeedbackRatingType.Three,
                ScreenName =  screenName,
                SessionId = Guid.NewGuid(),
                DateCreatedOnDevice =  dateCreatedOnDevice,
                Date = date,
                DateCreated = DateTime.Now,
                Version = version,
                PlatformId = platform
            };

            FeedbackSummary summary2 = new FeedbackSummary(feedback2);
            feedbackMapper.Save(summary2);

            IMongoQuery query = Query.And
                (
                    Query<FeedbackSummary>.EQ<DateTime>(mem => mem.Date, date),
                    Query<FeedbackSummary>.EQ<Guid>(mem => mem.ApplicationId, applicationId),
                    Query<FeedbackSummary>.EQ<string>(mem => mem.Version, version),
                    Query<FeedbackSummary>.EQ<PlatformType>(mem => mem.PlatformId, platform)
                );

            FeedbackSummary actual = this.GetCollection<FeedbackSummary>().FindOne(query);

            actual.ShouldHave().AllPropertiesBut(x => x.Id)
                .IncludingNestedObjects().EqualTo(expected);
        }