예제 #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
파일: AppsIndex.cs 프로젝트: jrlost/squidex
        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);
        }