public async Task <string> AddApiKey(ApiKey apiKey) { apiKey.Id = Guid.NewGuid().ToString(); await _apiKeyCommands.CreateAsync(apiKey.AppId, apiKey.Id, apiKey); return(apiKey.Id); }
public async Task CreateRole( ISiteRole role, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (role == null) { throw new ArgumentException("role cannot be null"); } if (role.SiteId == Guid.Empty) { throw new ArgumentException("SiteId must be provided"); } if (role.Id == Guid.Empty) { throw new ArgumentException("Id must be provided"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = role.SiteId.ToString(); var siteRole = SiteRole.FromISiteRole(role); if (siteRole.NormalizedRoleName.Length == 0) { siteRole.NormalizedRoleName = siteRole.RoleName; } await roleCommands.CreateAsync( projectId, siteRole.Id.ToString(), siteRole, cancellationToken).ConfigureAwait(false); }
public async Task CreateClaim( IUserClaim userClaim, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (userClaim == null) { throw new ArgumentException("userClaim cannnot be null"); } if (userClaim.Id == Guid.Empty) { throw new ArgumentException("userClaim must have an id"); } if (userClaim.SiteId == Guid.Empty) { throw new ArgumentException("userClaim must have n SiteId"); } if (userClaim.UserId == Guid.Empty) { throw new ArgumentException("userClaim must have a UserId"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = userClaim.SiteId.ToString(); var claim = UserClaim.FromIUserClaim(userClaim); await claimCommands.CreateAsync( projectId, claim.Id.ToString(), claim, cancellationToken).ConfigureAwait(false); }
//protected string projectId; //private async Task EnsureProjectId() //{ // if (string.IsNullOrEmpty(projectId)) // { // projectId = await projectResolver.ResolveProjectId().ConfigureAwait(false); // } //} #region User public async Task Create( ISiteUser user, CancellationToken cancellationToken = default(CancellationToken)) { if (user == null) { throw new ArgumentException("user cannot be null"); } if (user.SiteId == Guid.Empty) { throw new ArgumentException("user must have a siteid"); } if (user.Id == Guid.Empty) { throw new ArgumentException("user must have a non-empty id"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = user.SiteId.ToString(); var siteUser = SiteUser.FromISiteUser(user); await userCommands.CreateAsync( projectId, siteUser.Id.ToString(), siteUser, cancellationToken).ConfigureAwait(false); }
public async Task AddUserLocation( IUserLocation userLocation, CancellationToken cancellationToken = default(CancellationToken) ) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (userLocation == null) { throw new ArgumentException("userLocation must not be null"); } if (userLocation.Id == Guid.Empty) { throw new ArgumentException("Id must not be empty guid"); } if (userLocation.UserId == Guid.Empty) { throw new ArgumentException("UserId must not be empty guid"); } if (userLocation.SiteId == Guid.Empty) { throw new ArgumentException("SiteId must not be empty guid"); } await EnsureProjectId().ConfigureAwait(false); var ul = UserLocation.FromIUserLocation(userLocation); await locationCommands.CreateAsync( projectId, ul.Id.ToString(), ul, cancellationToken).ConfigureAwait(false); }
//protected string projectId; //private async Task EnsureProjectId() //{ // if (string.IsNullOrEmpty(projectId)) // { // projectId = await projectResolver.ResolveProjectId().ConfigureAwait(false); // } //} public async Task Create( ISiteSettings site, CancellationToken cancellationToken = default(CancellationToken)) { if (site == null) { throw new ArgumentException("site must not be null"); } if (site.Id == Guid.Empty) { throw new ArgumentException("site must have a non-empty Id"); } ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); //await EnsureProjectId().ConfigureAwait(false); var siteSettings = SiteSettings.FromISiteSettings(site); var projectId = siteSettings.Id.ToString(); await commands.CreateAsync( projectId, siteSettings.Id.ToString(), siteSettings, cancellationToken).ConfigureAwait(false); }
public async Task Create( string projectId, IPost post, CancellationToken cancellationToken = default(CancellationToken) ) { var p = Post.FromIPost(post); p.LastModified = DateTime.UtcNow; p.Id = _keyGenerator.GenerateKey(p); await _commands.CreateAsync(projectId, p.Id, p).ConfigureAwait(false); _cache.ClearListCache(projectId); }
public async Task <string> AddContentItem(ContentItem contentItem) { contentItem.Id = Guid.NewGuid().ToString(); await _contentItemCommands.CreateAsync(contentItem.AppId, contentItem.Id, contentItem); return(contentItem.Id); }
public async Task AddUserToRole( Guid siteId, Guid roleId, Guid userId, CancellationToken cancellationToken = default(CancellationToken) ) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (roleId == Guid.Empty) { throw new ArgumentException("roleId must be provided"); } if (userId == Guid.Empty) { throw new ArgumentException("userId must be provided"); } //await EnsureProjectId().ConfigureAwait(false); var projectId = siteId.ToString(); UserRole ur = new UserRole(); ur.RoleId = roleId; ur.UserId = userId; var key = userId.ToString() + "~" + roleId.ToString(); await userRoleCommands.CreateAsync( projectId, key, ur, cancellationToken).ConfigureAwait(false); }
public async Task Add( IGeoCountry geoCountry, CancellationToken cancellationToken = default(CancellationToken) ) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoCountry == null) { throw new ArgumentException("geoCountry must not be null"); } if (geoCountry.Id == Guid.Empty) { throw new ArgumentException("geoCountry must have a non-empty id"); } await EnsureProjectId().ConfigureAwait(false); var country = GeoCountry.FromIGeoCountry(geoCountry); // convert from IGeoCountry await countryCommands.CreateAsync( projectId, country.Id.ToString(), country, cancellationToken).ConfigureAwait(false); }
public async Task Add( ICurrency currency, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (currency == null) { throw new ArgumentException("currency must not be null"); } if (currency.Id == Guid.Empty) { throw new ArgumentException("currency must have a non-empty id"); } var c = Currency.FromICurrency(currency); await EnsureProjectId().ConfigureAwait(false); await currencyCommands.CreateAsync( projectId, c.Id.ToString(), c, cancellationToken).ConfigureAwait(false); }
public async Task Add( IGeoZone geoZone, CancellationToken cancellationToken = default(CancellationToken)) { ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); if (geoZone == null) { throw new ArgumentException("geoZone must not be null"); } if (geoZone.Id == Guid.Empty) { throw new ArgumentException("geoZone must have a non-empty id"); } await EnsureProjectId().ConfigureAwait(false); var state = GeoZone.FromIGeoZone(geoZone); // convert from IGeoZone await stateCommands.CreateAsync( projectId, state.Id.ToString(), state, cancellationToken).ConfigureAwait(false); }
public async Task AddHost( Guid siteId, string hostName, CancellationToken cancellationToken = default(CancellationToken)) { if (siteId == Guid.Empty) { throw new ArgumentException("siteId must not be empty guid"); } if (string.IsNullOrEmpty(hostName)) { throw new ArgumentException("hostName must be provided"); } ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); await EnsureProjectId().ConfigureAwait(false); var host = new SiteHost(); host.SiteId = siteId; host.HostName = hostName; await hostCommands.CreateAsync( projectId, host.Id.ToString(), host, cancellationToken).ConfigureAwait(false); }
public async Task CreateSubscription(PushDeviceSubscription subscription) { await _commands.CreateAsync( _NoDbProjectId, subscription.Key.ToString(), subscription ).ConfigureAwait(false); }
public async Task <string> AddContentCollection(ContentCollection contentCollection) { contentCollection.Id = Guid.NewGuid().ToString(); var projectId = contentCollection.ContentType.AppId; await _contentCollectionCommands.CreateAsync(projectId, contentCollection.Id, contentCollection); return(contentCollection.Id); }
public async Task <bool> CreateMovie(Movie movie) { await _movieCommands.CreateAsync(projectId, movie.Id.ToString(), movie).ConfigureAwait(false); _cache.Remove(moviesCacheKey); return(true); }
public async Task Create(JournalEntry entry) { string journalId = entry.Timestamp.Ticks.ToString(); entry.Id = journalId; await commands.CreateAsync(PROJECT_ID, entry.Id, entry); }
public async Task <string> AddContentType(ContentType contentType) { var projectId = contentType.AppId ?? Constants.GlobalProjectId; contentType.Id = Guid.NewGuid().ToString(); await _commands.CreateAsync(projectId, contentType.Id, contentType); return(contentType.Id); }
public async Task Create( string projectId, IPost post, CancellationToken cancellationToken = default(CancellationToken) ) { var p = Post.FromIPost(post); p.LastModified = DateTime.UtcNow; // metaweblog sets the id, don't change it if it exists if (string.IsNullOrWhiteSpace(p.Id)) { p.Id = _keyGenerator.GenerateKey(p); } await _commands.CreateAsync(projectId, p.Id, p).ConfigureAwait(false); _cache.ClearListCache(projectId); }
public IActionResult AddEventTest() { var eventCount = _eventQueries.GetAllAsync("BibleBrowserTest").Result.Count() + 1; var e = new Event($"Test Event {eventCount.ToString()}", new EventRelationship.Absolute(new ApproximateDateTime())); _eventCommands.CreateAsync("BibleBrowserTest", e.Id.ToString(), e); var events = _eventQueries.GetAllAsync("BibleBrowserTest").Result; return(View(events)); }
public async Task <IActionResult> CreateQuestion(Question question) { var count = _pageQueriesQuestion.GetCountAsync("Cues").Result; question.Id = count + 1; question.Sequence = new Random().Next(0, 100000000); question.InternalName = question.Title.ToSlug(); await _pageCommandsQuestion.CreateAsync("Cues", question.Id.ToString(), question); return(CreatedAtAction("GetQuestion", new { id = question.Id }, question)); }
public async Task <IActionResult> PostMovie([FromBody] Movie movie) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } await _movieCommands.CreateAsync(projectId, movie.Id.ToString(), movie).ConfigureAwait(false); _cache.Remove(moviesCacheKey); return(CreatedAtAction("GetMovie", new { id = movie.Id }, movie)); }
// private ILogger log; public async Task HandlePubDateAboutToChange( string projectId, IPost post, DateTime newPubDate, CancellationToken cancellationToken = default(CancellationToken)) { if ((post.PubDate.Month == newPubDate.Month) && (post.PubDate.Year == newPubDate.Year)) { // we store posts in /year/month folders, if that didn't change no need to do anything return; } // because with the filesystem storage we are storing posts in a year/month folder // if the year or month changes we need to delete the old file and save the updated post to the // new year/month folder var p = Post.FromIPost(post); await commands.DeleteAsync(projectId, p.Id).ConfigureAwait(false); p.PubDate = newPubDate; await commands.CreateAsync(projectId, p.Id, p).ConfigureAwait(false); }
//private ILogger _log; public async Task Create( string projectId, IPage page, CancellationToken cancellationToken = default(CancellationToken) ) { var p = Page.FromIPage(page); p.Id = _keyGenerator.GenerateKey(p); p.LastModified = DateTime.UtcNow; await _commands.CreateAsync(projectId, p.Id, p).ConfigureAwait(false); }
public async Task Create( string projectId, IKvpItem kvp, CancellationToken cancellationToken = default(CancellationToken) ) { var item = KvpItem.FromIKvpItem(kvp); await _kvpCommands.CreateAsync( projectId, item.Id, item, cancellationToken).ConfigureAwait(false); }
public async Task Create( string projectId, IProjectSettings project, CancellationToken cancellationToken = default(CancellationToken) ) { if (string.IsNullOrEmpty(project.Id)) { project.Id = Guid.NewGuid().ToString(); } var p = ProjectSettings.FromIProjectSettings(project); await commands.CreateAsync(projectId, p.Id, p).ConfigureAwait(false); }
public async Task StoreDeviceAuthorizationAsync(string deviceCode, string userCode, DeviceCode data) { var site = _contextAccessor.HttpContext.GetTenant <SiteContext>(); if (site == null) { _logger.LogError("sitecontext was null"); return; } var siteId = site.Id.ToString(); var entity = ToEntity(data, deviceCode, userCode, siteId); await _commands.CreateAsync(siteId, userCode, entity); }
private async Task SaveClientClaims(string siteId, Client client, CancellationToken cancellationToken = default(CancellationToken)) { foreach (var c in client.Claims) { var cc = new ClientClaim { Id = Guid.NewGuid().ToString(), ClientId = client.ClientId, Type = c.Type, Value = c.Value }; await _claimCommands.CreateAsync(siteId, cc.Id, cc, cancellationToken).ConfigureAwait(false); } }
public async Task <IActionResult> CreateCategory([FromBody] Category category) { category.Id = new Random().Next(0, 100000000); category.InternalName = category.Title.ToSlug(); if (category.ParentCategoryId == 0) { await _pageCommandsCategory.CreateAsync("Cues", category.Id.ToString(), category); return(CreatedAtAction("GetCategory", new { id = category.Id }, category)); } var findParent = await _pageQueriesCategory.FetchAsync("Cues", category.ParentCategoryId.ToString()); if (findParent != null) { await _pageCommandsCategory.CreateAsync("Cues", category.Id.ToString(), category); return(CreatedAtAction("GetCategory", new { id = category.Id }, category)); } return(BadRequest()); }
public async Task CreateLogin( IUserLogin userLogin, CancellationToken cancellationToken = default(CancellationToken)) { if (userLogin == null) { throw new ArgumentException("userLogin can't be null"); } if (userLogin.LoginProvider.Length == -1) { throw new ArgumentException("LoginProvider must be provided"); } if (userLogin.ProviderKey.Length == -1) { throw new ArgumentException("ProviderKey must be provided"); } if (userLogin.UserId == Guid.Empty) { throw new ArgumentException("UserId must be provided"); } if (userLogin.SiteId == Guid.Empty) { throw new ArgumentException("SiteId must be provided"); } ThrowIfDisposed(); cancellationToken.ThrowIfCancellationRequested(); //await EnsureProjectId().ConfigureAwait(false); var projectId = userLogin.SiteId.ToString(); var login = UserLogin.FromIUserLogin(userLogin); // this will be a tricky one for queries because the key consists of 4 columns // TODO: review this and whether we really need all the parts of the key in EF // http://www.jerriepelser.com/blog/using-aspnet-oauth-providers-without-identity // ProviderKey is the unique key associated with the login on that service var key = login.UserId.ToString() + "~" + login.SiteId.ToString() + "~" + login.LoginProvider + "~" + login.ProviderKey; await loginCommands.CreateAsync( projectId, key, login, cancellationToken).ConfigureAwait(false); }