示例#1
0
        private async Task AddAsync()
        {
            ConsoleHelper.ShowHeading("Add superstar");

            string  name     = ConsoleHelper.GetString("Enter name: ");
            decimal heightCm = ConsoleHelper.GetDecimal("Enter height (cm): ");
            decimal weightKg = ConsoleHelper.GetDecimal("Enter weight (kg): ");
            int     genderId = ConsoleHelper.GetInt("Enter gender id: ");
            int     brandId  = ConsoleHelper.GetInt("Enter brand id: ");
            int     cityId   = ConsoleHelper.GetInt("Enter city id: ");

            SuperstarSaveDto superstarSaveDto = new SuperstarSaveDto
            {
                Name     = name,
                HeightCm = heightCm,
                WeightKg = weightKg,
                GenderID = genderId,
                BrandID  = brandId,
                CityID   = cityId
            };

            await ConsoleHelper.RunWithTryCatchAsync(async() =>
            {
                SaveResponseDto <SuperstarReadDto> saveResponseDto = await _superstarApi.AddAsync(superstarSaveDto);
                ConsoleHelper.ShowSaveResponseDto(saveResponseDto);
            }, "An error occurred while saving data.");
        }
示例#2
0
        public static void ShowSaveResponseDto <TSaveDto>(SaveResponseDto <TSaveDto> saveResponseDto)
        {
            Console.WriteLine();
            ShowHeading("Response");

            if (saveResponseDto.IsSuccessful)
            {
                ShowSingleData(saveResponseDto.Data, saveResponseDto.PropertyInfoListOfDto);
                ShowGreenMessage(saveResponseDto.Message);
            }
            else
            {
                ShowRedMessage(saveResponseDto.Message);
            }

            if (!saveResponseDto.ValidationResults.IsEmpty())
            {
                Console.WriteLine();
                ShowRedMessage("Validation result");
                ShowRedMessage("------------------");

                foreach (var validationResult in saveResponseDto.ValidationResults)
                {
                    foreach (var errorMessage in validationResult.ErrorMessages)
                    {
                        ShowRedMessage($"{validationResult.PropertyName}: {errorMessage}");
                    }
                }
            }
        }
        private async Task AddAsync()
        {
            ConsoleHelper.ShowHeading("Add gender");

            string name = ConsoleHelper.GetString("Enter name: ");

            GenderSaveDto genderSaveDto = new GenderSaveDto
            {
                Name = name
            };

            await ConsoleHelper.RunWithTryCatchAsync(async() =>
            {
                SaveResponseDto <GenderReadDto> saveResponseDto = await _genderApi.AddAsync(genderSaveDto);
                ConsoleHelper.ShowSaveResponseDto(saveResponseDto);
            }, "An error occurred while saving data.");
        }
        private async Task AddAsync()
        {
            ConsoleHelper.ShowHeading("Add country");

            string name = ConsoleHelper.GetString("Enter name: ");

            CountrySaveDto countrySaveDto = new CountrySaveDto
            {
                Name = name
            };

            await ConsoleHelper.RunWithTryCatchAsync(async() =>
            {
                SaveResponseDto <CountryReadDto> saveResponseDto = await _countryApi.AddAsync(countrySaveDto);
                ConsoleHelper.ShowSaveResponseDto(saveResponseDto);
            }, "An error occurred while saving data.");
        }
示例#5
0
        private async Task AddAsync()
        {
            ConsoleHelper.ShowHeading("Add brand");

            string name = ConsoleHelper.GetString("Enter name: ");

            BrandSaveDto brandSaveDto = new BrandSaveDto
            {
                Name = name
            };

            await ConsoleHelper.RunWithTryCatchAsync(async() =>
            {
                SaveResponseDto <BrandReadDto> saveResponseDto = await _brandApi.AddAsync(brandSaveDto);
                ConsoleHelper.ShowSaveResponseDto(saveResponseDto);
            }, "An error occurred while saving data.");
        }
示例#6
0
        private async Task AddAsync()
        {
            ConsoleHelper.ShowHeading("Add city");

            string name      = ConsoleHelper.GetString("Enter name: ");
            int    countryId = ConsoleHelper.GetInt("Enter country id: ");

            CitySaveDto citySaveDto = new CitySaveDto
            {
                Name      = name,
                CountryID = countryId
            };

            await ConsoleHelper.RunWithTryCatchAsync(async() =>
            {
                SaveResponseDto <CityReadDto> saveResponseDto = await _cityApi.AddAsync(citySaveDto);
                ConsoleHelper.ShowSaveResponseDto(saveResponseDto);
            }, "An error occurred while saving data.");
        }