public PaymentTypeRepositoryFixture()
        {
            MockPaymentTypeService = new Mock <IPaymentTypeService>();

            PaymentTypes = new List <PaymentType> {
                new PaymentType {
                    Id = 1, Name = "Cash", CreditPeriod = 0
                },
                new PaymentType {
                    Id = 2, Name = "Credit", CreditPeriod = 15
                }
            };

            CreatePaymentTypeDto = new CreatePaymentTypeDto {
                Name = "Credit1", CreditPeriod = 15
            };

            CreatedNewPaymentType = new PaymentType {
                Id = 3, Name = CreatePaymentTypeDto.Name, CreditPeriod = CreatePaymentTypeDto.CreditPeriod
            };

            EditPaymentTypeDto = new EditPaymentTypeDto {
                Name = "Credit", CreditPeriod = 20
            };
        }
예제 #2
0
        public PaymentTypeControllerFixture()
        {
            ApiVersion = new ApiVersion(1, 0);

            MockPaymentTypeRepository = new Mock <IPaymentTypeRepository>();

            PaymentTypes = new List <GetPaymentTypeDto> {
                new GetPaymentTypeDto {
                    Id = 1, Name = "Cash", CreditPeriod = 0
                },
                new GetPaymentTypeDto {
                    Id = 2, Name = "Credit", CreditPeriod = 30
                }
            };

            ValidCreatePaymentTypeDto = new CreatePaymentTypeDto {
                Name = "Credit1", CreditPeriod = 15
            };

            CreatePaymentTypeDtoResult = new GetPaymentTypeDto {
                Id = 3, Name = "Credit1", CreditPeriod = 15
            };

            ValidUpdatePaymentTypeDto = new EditPaymentTypeDto {
                Name = "Credit", CreditPeriod = 20
            };

            EditPaymentTypeDtoResult = new GetPaymentTypeDto {
                Id = 2, Name = "Credit", CreditPeriod = 20
            };
        }
예제 #3
0
        public async Task <GetPaymentTypeDto> CreatePaymentTypeAsync(CreatePaymentTypeDto paymentTypeDto)
        {
            await CheckPaymentTypeAsync(0, paymentTypeDto.Name);

            var paymentType = _mapper.Map <PaymentType>(paymentTypeDto);

            paymentType = await _paymentType.AddPaymentTypeAsync(paymentType);

            return(_mapper.Map <GetPaymentTypeDto>(paymentType));
        }
        public CreatePaymentTypeDtoValidatorFixture()
        {
            Validator = new CreatePaymentTypeDtoValidator();

            Model = new CreatePaymentTypeDto
            {
                Name         = "Credit",
                CreditPeriod = 30
            };
        }
예제 #5
0
        public async Task <IActionResult> CreatePaymentType(CreatePaymentTypeDto paymentTypeDto, ApiVersion version)
        {
            var result = await _repository.CreatePaymentTypeAsync(paymentTypeDto);

            return(CreatedAtRoute(new { id = result.Id, version = $"{version}" }, result));
        }