/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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 }; }
/// <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); }
public async Task <OperationResult> UpsertAppCounters(AppCounters appCounters) { await Task.Factory.StartNew(() => { AppCounters = appCounters; }); return(new OperationResult(OperationResultStatus.Success)); }
public async Task <OperationResult> UpsertAppCounters(AppCounters appCounters) { var azureModel = appCounters.ToAzureModel(); return(await _azureManager.UpsertEntityAsync(azureModel, false)); }