public UserRepository() { var storageCredentials = new StorageCredentials(AccountName, AccountKey); var storageAccount = new CloudStorageAccount(storageCredentials, true); UserContext = new CloudTableContext<User>(storageAccount, "UserId"); // UserContext.UseBackgroundTaskForIndexing = false; InitPartitionSchemas(); }
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)); }
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 }); }
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"] ); }
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 }); }
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); }