PhotoSharingApp.AppService.Controllers.CategoryController.PostAsync C# (CSharp) Метод

PostAsync() приватный Метод

private PostAsync ( string name ) : Task
name string
Результат Task
        public async Task<CategoryContract> PostAsync(string name)
        {
            try
            {
                _telemetryClient.TrackEvent("CategoryController PostAsync invoked");
                await ValidateAndReturnCurrentUserId();

                var sanitizedName = name.TrimAndReplaceMultipleWhitespaces().ToTitleCase();

                return await _repository.CreateCategory(sanitizedName);
            }
            catch (DataLayerException ex)
            {
                _telemetryClient.TrackException(ex);

                if (ex.Error == DataLayerError.Unknown)
                {
                    throw ServiceExceptions.UnknownInternalFailureException(ServiceExceptions.Source);
                }
                if (ex.Error == DataLayerError.DuplicateKeyInsert)
                {
                    throw ServiceExceptions.DuplicateCategoryException(ServiceExceptions.Source);
                }

                throw ServiceExceptions.DataLayerException(ex.Message);
            }
        }
    }