예제 #1
0
        /// <summary>
        /// To the azure model.
        /// </summary>
        /// <param name="appCounters">The application counters.</param>
        /// <returns></returns>
        public static AppCountersAzure ToAzureModel(this AppCounters appCounters)
        {
            var azureModel = new AppCountersAzure();

            appCounters.CopyTo(azureModel);
            return(azureModel);
        }
예제 #2
0
        /// <summary>
        ///     User passed first mission.
        /// </summary>
        /// <returns></returns>
        public async Task <OperationResult> UserPassedFirstMission()
        {
            //TODO concurrency management (with Etag in repository)
            var counters = await _appCountersRepository.GetAppCounters();

            var updatingCounter = new AppCounters {
                OneMissionPassedUsers = (counters.OneMissionPassedUsers ?? 0) + 1
            };

            return(await _appCountersRepository.UpsertAppCounters(updatingCounter));
        }
예제 #3
0
        /// <summary>
        ///     User passed last mission.
        /// </summary>
        /// <returns></returns>
        public async Task <OperationResult> UserHasFinished()
        {
            //TODO concurrency management (with Etag in repository)
            var counters = await _appCountersRepository.GetAppCounters();

            var updatingCounter = new AppCounters {
                FinishedUsers = (counters.FinishedUsers ?? 0) + 1
            };

            return(await _appCountersRepository.UpsertAppCounters(updatingCounter));
        }
예제 #4
0
        /// <summary>
        ///     Users passed test
        /// </summary>
        /// <returns></returns>
        public async Task <OperationResult> QuestionsAnswered()
        {
            //TODO concurrency management (with Etag in repository)
            var counters = await _appCountersRepository.GetAppCounters();

            var updatingCounter = new AppCounters {
                TestPassed = (counters.TestPassed ?? 0) + 1
            };

            return(await _appCountersRepository.UpsertAppCounters(updatingCounter));
        }
예제 #5
0
        /// <summary>
        ///     Users submited a kind action
        /// </summary>
        /// <returns></returns>
        public async Task <OperationResult> KindActionSubmited()
        {
            //TODO concurrency management (with Etag in repository)
            var counters = await _appCountersRepository.GetAppCounters();

            var updatingCounter = new AppCounters {
                KindActionsSubmited = (counters.KindActionsSubmited ?? 0) + 1
            };

            return(await _appCountersRepository.UpsertAppCounters(updatingCounter));
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AppCountersRepository"/> class.
 /// </summary>
 public AppCountersRepository()
 {
     AppCounters = new AppCounters
     {
         FinishedUsers         = 10,
         KindActionsSubmited   = 200,
         OneMissionPassedUsers = 100,
         RegisteredUsers       = 150,
         TestPassed            = 80,
         VkReposts             = 30
     };
 }
예제 #7
0
        /// <summary>
        ///     Froms the azure model.
        /// </summary>
        /// <param name="azureModel">The azure model.</param>
        /// <returns>AppErrorInfo.</returns>
        public static AppCounters FromAzureModel(this AppCountersAzure azureModel)
        {
            if (azureModel == null)
            {
                return(null);
            }

            var domainModel = new AppCounters();

            azureModel.CopyTo(domainModel);
            return(domainModel);
        }
예제 #8
0
        public async Task <OperationResult> UpsertAppCounters(AppCounters appCounters)
        {
            await Task.Factory.StartNew(() => { AppCounters = appCounters; });

            return(new OperationResult(OperationResultStatus.Success));
        }
예제 #9
0
        public async Task <OperationResult> UpsertAppCounters(AppCounters appCounters)
        {
            var azureModel = appCounters.ToAzureModel();

            return(await _azureManager.UpsertEntityAsync(azureModel, false));
        }