public async Task CheckValidityAsync(CallContext callContext) { if (QueryValidationHelper.IsReservedGuid(UserId)) { throw new InvalidOperationException("Invalid user id"); } if (QueryValidationHelper.IsReservedGuid(ImageId)) { throw new InvalidOperationException("Invalid image id"); } var imageDataBeforeUpdate = await callContext.DbContext.Images .AsNoTracking() .Where(img => img.Id == ImageId) .Select(img => new { nameBeforeUpdate = img.Name, sourceBeforeUpdate = img.Source, descriptionBeforeUpdate = img.Description }) .SingleAsync(); if (imageDataBeforeUpdate.nameBeforeUpdate == Name && imageDataBeforeUpdate.sourceBeforeUpdate == Source && imageDataBeforeUpdate.descriptionBeforeUpdate == Description) { throw new RequestInputException(callContext.Localized.Get("CanNotUpdateMetadataBecauseSameAsOriginal")); } if (imageDataBeforeUpdate.nameBeforeUpdate != Name) { await QueryValidationHelper.CheckCanCreateImageWithNameAsync(Name, callContext.DbContext, callContext.Localized); } QueryValidationHelper.CheckCanCreateImageWithSource(Source, callContext.Localized); QueryValidationHelper.CheckCanCreateImageWithDescription(Description, callContext.Localized); QueryValidationHelper.CheckCanCreateImageWithVersionDescription(VersionDescription, callContext.Localized); }