public void Save(DeviceUpgradeSummary summary)
 {
     this.deviceMapper.Save(summary);
 }
        public void Save(DeviceUpgradeSummary entity)
        {
            try
            {
                IMongoQuery query = Query.And
                    (
                        Query<DeviceUpgradeSummary>.EQ<DateTime>(mem => mem.Date, entity.Date),
                        Query<DeviceUpgradeSummary>.EQ<Guid>(mem => mem.ApplicationId, entity.ApplicationId),
                        Query<DeviceUpgradeSummary>.EQ<string>(mem => mem.Version, entity.Version),
                        Query<DeviceUpgradeSummary>.EQ<PlatformType>(mem => mem.PlatformType, entity.PlatformType)
                    );

                IMongoUpdate update = Update<DeviceUpgradeSummary>
                    .SetOnInsert(x => x.Version, entity.Version)
                    .SetOnInsert(x => x.Date, entity.Date)
                    .SetOnInsert(x => x.ApplicationId, entity.ApplicationId)
                    .SetOnInsert(x => x.PlatformType, entity.PlatformType)
                    .Inc(mem => mem.Count, entity.Count);

                this.GetCollection<DeviceUpgradeSummary>().FindAndModify(query, SortBy.Null, update, false, true);
            }
            catch (Exception ex)
            {
                throw new DataAccessLayerException(ex);
            }
        }
        public void Log(UpgradeInfo upgradeInfo)
        {
            Application application = this.applicationRepository.Find(upgradeInfo.ApplicationId);

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

                if (device != null)
                {
                    DeviceUpgradeSummary deviceUpgradeSum =
                        new DeviceUpgradeSummary(upgradeInfo.Version, DateTime.Today, upgradeInfo.ApplicationId, device.PlatformType);

                    this.deviceRepository.Save(deviceUpgradeSum);
                }
                else
                {
                    throw new NoDeviceException(upgradeInfo.DeviceId);
                }
            }
            else
            {
                throw new InactiveApplicationException(upgradeInfo.ApplicationId);
            }
        }