示例#1
0
        private async Task <string?> CheckAppAsync(IAppsCacheGrain cache, CreateApp command)
        {
            var token = await cache.ReserveAsync(command.AppId, command.Name);

            if (token == null)
            {
                throw new ValidationException(T.Get("apps.nameAlreadyExists"));
            }

            try
            {
                var existingId = await GetAppIdAsync(command.Name);

                if (existingId != default)
                {
                    throw new ValidationException(T.Get("apps.nameAlreadyExists"));
                }
            }
            catch
            {
                // Catch our own exception, just in case something went wrong before.
                await cache.RemoveReservationAsync(token);

                throw;
            }

            return(token);
        }
示例#2
0
        private static async Task <string?> CheckAppAsync(IAppsCacheGrain cache, CreateApp command)
        {
            var token = await cache.ReserveAsync(command.AppId, command.Name);

            if (token == null)
            {
                throw new ValidationException(T.Get("apps.nameAlreadyExists"));
            }

            return(token);
        }