Пример #1
0
        public UserRepository()
        {
            var storageCredentials = new StorageCredentials(AccountName, AccountKey);
            var storageAccount = new CloudStorageAccount(storageCredentials, true);
            UserContext = new CloudTableContext<User>(storageAccount, "UserId");
            // UserContext.UseBackgroundTaskForIndexing = false;

            InitPartitionSchemas();
        }
Пример #2
0
        public ActionResult Index()
        {
            var context = new CloudTableContext();
            var user = ((User)HttpContext.User.Identity);
            var players = context.GetPlayers(user).Where(p => p.Included);
            var settings = context.GetSettings(user);

            return View(new PlayViewModel(players, settings));
        }
Пример #3
0
        public JsonResult SaveSettings(Settings settings)
        {
            try
            {
                var context = new CloudTableContext();
                context.SaveSettings((User)HttpContext.User.Identity, settings);
            }
            catch (Exception exception)
            {
                //TODO:logging of exception!
                return Json(new { Success = false, ErrorMessage = exception.Message });
            }

            return Json(new { Success = true });
        }
Пример #4
0
 public void ConfigureStorage()
 {
     CloudFileContext.InitializeContext(
         Configuration["AzureCloudStorage:UserStoreName"],
         Configuration["AzureCloudStorage:UserStoreKey"]
         );
     CloudTableContext.InitializeContext(
         Configuration["AzureCloudStorage:UserStoreName"],
         Configuration["AzureCloudStorage:UserStoreKey"]
         );
     CosmosContext.InitializeContext(
         Configuration["CosmosDb:Database"],
         Configuration["CosmosDb:Endpoint"],
         Configuration["CosmosDb:Key"]
         );
 }
Пример #5
0
        public JsonResult SavePlayer(Player player)
        {
            string playerId;
            try
            {
                var context = new CloudTableContext();
                playerId = context.SavePlayer((User)HttpContext.User.Identity, player);
            }
            catch (Exception exception)
            {
                //TODO:logging of exception!
                return Json(new { Success = false, ErrorMessage = exception.Message });
            }

            return Json(new { Success = true, Id = playerId });
        }
Пример #6
0
        public JsonResult DeletePlayer(Player player)
        {
            try
            {
                var context = new CloudTableContext();
                context.DeletePlayer((User)HttpContext.User.Identity, player);
            }
            catch (Exception exception)
            {
                //TODO:logging of exception!
                //return new HttpResponseMessage(HttpStatusCode.InternalServerError);
                return Json(new { Success = false, ErrorMessage = exception.Message });
            }

            return Json(new { Success = true });
        }
 private void Init(CloudStorageAccount storageAccount)
 {
     _domainEventContext = new CloudTableContext<DomainEvent>(storageAccount, AggregateRootIdPropName);
     _latestVersionPartition = _domainEventContext.CreatePartitionSchema("LatestVersionPartition")
                                                  .SetRowKeyCriteria(domainEvt => domainEvt.AggregateRootId.SerializeToString())
                                                  .SetSchemaCriteria(domainEvt => true)
                                                  .SetIndexedPropertyCriteria(domainEvt => domainEvt.Sequence);
     _domainEventContext.AddPartitionSchema(_latestVersionPartition);
 }