Esempio n. 1
0
        public void ListBasic_EndingNotSpecifiedStartingAfterSpecified_ValidationSuccess()
        {
            ListBasicViewModel viewModel = new ListBasicViewModel(
                endingBefore: null,
                startingAfter: 1110,
                limit: 10);

            Assert.IsTrue(viewModel.Result.IsValid);
        }
Esempio n. 2
0
        public void ListBasic_LimitExceedsTreshod_ValidationError(int value)
        {
            ListBasicViewModel viewModel = new ListBasicViewModel(
                endingBefore: null,
                startingAfter: null,
                limit: value);

            Assert.IsFalse(viewModel.Result.IsValid);
        }
Esempio n. 3
0
        public void ListBasic_NullStartingEndinCategory_ValidationSuccess()
        {
            ListBasicViewModel viewModel = new ListBasicViewModel(
                endingBefore: null,
                startingAfter: null,
                limit: 10);

            Assert.IsTrue(viewModel.Result.IsValid);
        }
Esempio n. 4
0
        public void ListBasic_EndingSpecifiedStartingAfterSpecified_ValidationError()
        {
            ListBasicViewModel viewModel = new ListBasicViewModel(
                endingBefore: 1110,
                startingAfter: 1112,
                limit: 10);

            Assert.IsFalse(viewModel.Result.IsValid);
            Assert.That(viewModel.Result.Errors.FirstOrDefault().ErrorMessage.Equals("'StartingAfter' cannot be specified when 'EndingBefore' is specified"));
        }
Esempio n. 5
0
        public async Task <Result <VehicleCategoryModel[]> > ListVehicleCategory(ListBasicViewModel query)
        {
            if (!query.Result.IsValid)
            {
                _logger.LogError($"Validation failed: {query.Result.Errors.FirstOrDefault()}");
                return(Result.Fail(new Error(query.Result.Errors.FirstOrDefault().ToString())));
            }

            IEnumerable <VehicleCategoryModel> categories = await _vehicleRepository.ListVehicleCategories(
                EndingBefore : query.EndingBefore,
                StartingAfter : query.StartingAfter,
                Limit : query.Limit).ConfigureAwait(false);

            _logger.LogInformation("Vehicle Categories Listed Succesfully");
            return(Result.Ok(categories.ToArray())
                   .WithSuccess("Vehicle Categories Listed Succesfully"));
        }