public async Task <DtoResult> UpdateFeatureStateAsync(ShellFeatureState featureState, CancellationToken cancellationToken) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (featureState == null) { throw new ArgumentNullException(nameof(featureState)); } var model = await ShellFeatureStates.SingleOrDefaultAsync(c => c.Id == featureState.Id); model.EnableState = featureState.EnableState; model.InstallState = featureState.InstallState; Context.Update(model); try { await SaveChanges(cancellationToken); } catch (DbUpdateConcurrencyException) { return(DtoResult.Failed(new DtoError { Code = "ConcurrencyFailure", Description = "并发故障" })); } return(DtoResult.Success); }
private async Task <DtoResult> ValidateTencentVodInternal(TVod article) { var errors = new List <DtoError>(); foreach (var v in TencentVodValidators) { var result = await v.ValidateAsync(this, article); if (!result.Succeeded) { errors.AddRange(result.Errors); } } if (errors.Count > 0) { //Logger.LogWarning(0, "Role {roleId} validation failed: {errors}.", await GetRoleIdAsync(role), string.Join(";", errors.Select(e => e.Code))); return(DtoResult.Failed(errors.ToArray())); } return(DtoResult.Success); }
public virtual async Task <DtoResult> DeleteAsync(TencentVod vod, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (vod == null) { throw new ArgumentNullException(nameof(vod)); } Context.Remove(vod); try { await SaveChanges(cancellationToken); } catch (DbUpdateConcurrencyException) { return(DtoResult.Failed(ErrorDescriber.ConcurrencyFailure())); } return(DtoResult.Success); }
public virtual async Task <DtoResult> ValidateAsync(TencentVodManager <TTencentVod> manager, TTencentVod article) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } if (article == null) { throw new ArgumentNullException(nameof(article)); } var errors = new List <DtoError>(); await ValidateTitle(manager, article, errors); //if (manager.Options.User.RequireUniqueEmail) //{ // await ValidateEmail(manager, user, errors); //} return(errors.Count > 0 ? DtoResult.Failed(errors.ToArray()) : DtoResult.Success); }
public virtual async Task <DtoResult> UpdateAsync(TencentVod article, CancellationToken cancellationToken = default(CancellationToken)) { cancellationToken.ThrowIfCancellationRequested(); ThrowIfDisposed(); if (article == null) { throw new ArgumentNullException(nameof(article)); } Context.Attach(article); //article.ConcurrencyStamp = Guid.NewGuid().ToString(); Context.Update(article); try { await SaveChanges(cancellationToken); } catch (DbUpdateConcurrencyException) { return(DtoResult.Failed(ErrorDescriber.ConcurrencyFailure())); } return(DtoResult.Success); }