Пример #1
0
                public async Task <ResultModel <ProductDto> > Handle(Command request, CancellationToken cancellationToken)
                {
                    var productCode =
                        await _productCodeRepository.AddAsync(ProductCode.Create(request.Model.ProductCodeName));

                    if (productCode is null)
                    {
                        throw new Exception($"Couldn't find Product Code with name={request.Model.ProductCodeName}");
                    }

                    var created = await _productRepository.AddAsync(
                        Product.Create(
                            request.Model.Name,
                            request.Model.Quantity,
                            request.Model.Cost,
                            productCode));

                    return(ResultModel <ProductDto> .Create(new ProductDto
                    {
                        Id = created.Id,
                        Name = created.Name,
                        Active = created.Active,
                        Cost = created.Cost,
                        Quantity = created.Quantity,
                        Created = created.Created,
                        Updated = created.Updated,
                        ProductCodeId = created.ProductCodeId
                    }));
                }
        public StubDataProductRepository(MemoryRepository <Product> memRepository)
        {
            this.memRepository = memRepository;

            this.memRepository.Add(Product.Create(new Guid("65D03D7E-E41A-49BC-8680-DC942BABD10A"), "iPhone", 2, 500.02m,
                                                  ProductCode.Create(new Guid("B2773EBF-CD0C-4F31-83E2-691973E32531"), "HD")));
        }
Пример #3
0
        internal PeriodPass(FFIPeriodPass periodPass)
        {
            ProductCode1     = ProductCode.Create(periodPass.product_code_1_kind, periodPass.product_code_1_value);
            ValidityArea1    = ValidityArea.Create(periodPass.validity_area_1_kind, periodPass.validity_area_1_buffer);
            PeriodStartDate1 = DateTimeOffset.FromUnixTimeSeconds(periodPass.period_start_date_1);
            PeriodEndDate1   = DateTimeOffset.FromUnixTimeSeconds(periodPass.period_end_date_1);

            ProductCode2     = ProductCode.Create(periodPass.product_code_2_kind, periodPass.product_code_2_value);
            ValidityArea2    = ValidityArea.Create(periodPass.validity_area_2_kind, periodPass.validity_area_2_buffer);
            PeriodStartDate2 = DateTimeOffset.FromUnixTimeSeconds(periodPass.period_start_date_2);
            PeriodEndDate2   = DateTimeOffset.FromUnixTimeSeconds(periodPass.period_end_date_2);

            LoadedPeriodProduct    = ProductCode.Create(periodPass.loaded_period_product_kind, periodPass.loaded_period_product_value);
            LoadedPeriodDateTime   = DateTimeOffset.FromUnixTimeSeconds(periodPass.loaded_period_datetime);
            LoadedPeriodLength     = periodPass.loaded_period_length;
            LoadedPeriodPrice      = periodPass.loaded_period_price;
            LoadingOrganizationId  = periodPass.loading_organization;
            LoadingDeviceNumber    = periodPass.loading_device_number;
            LastBoardDateTime      = DateTimeOffset.FromUnixTimeSeconds(periodPass.last_board_datetime);
            LastBoardVehicleNumber = periodPass.last_board_vehicle_number;
            LastBoardLocation      = BoardingLocation.Create(periodPass.last_board_location_kind, periodPass.last_board_location_value);
            LastBoardDirection     = periodPass.last_board_direction;
            LastBoardArea          = BoardingArea.Create(periodPass.last_board_area_kind, periodPass.last_board_area_value);
        }
Пример #4
0
        public CartDTO Add(Guid customerId, CartProductDTO cartProductDto)
        {
            CartDTO cartDto = null;
            Cart    cart    = null;

            CustomerDTO customerDto = this.customerRepository.FindOne(c => c.Id == customerId);

            if (customerDto == null)
            {
                throw new Exception(String.Format("Customer was not found with this Id: {0}", customerId));
            }

            Customer customer = Customer.Create(
                new PlainText(customerDto.FirstName),
                new PlainText(customerDto.LastName),
                new Email(customerDto.Email),
                Country.Create(new PlainText("Romania"))
                );

            cartDto = this.cartRepository.FindOne(c => c.CustomerId == customerId);
            if (cartDto == null)
            {
                cart = Cart.Create(customer);
            }
            else
            {
                cart = new Cart()
                {
                    CustomerId = customerId,
                    Id         = cartDto.Id
                };

                //foreach(var cardP in cartDto.Products)
                //{
                //    cart.Add(cardP);
                //}
            }

            ProductDTO productDto = this.productRepository.FindOne(c => c.Id == cartProductDto.ProductId);
            Product    product    = Product.Create(
                new PlainText(productDto.Name),
                new Quantity(productDto.Quantity),
                new Cost(productDto.Cost),
                ProductCode.Create(new PlainText("test")),
                new PlainText(productDto.Description),
                productDto.Image
                );

            var cartP = CartProduct.Create(customer, cart, product, new Quantity(1));

            cart.Add(new CartProductDTO()
            {
                Id        = cartP.Id,
                CartDTOId = cart.Id,
                ProductId = cartP.ProductId
            });
            Console.WriteLine(JsonConvert.SerializeObject(cart));
            // cartDto = _mapper.Map<Cart, CartDTO>(cart);
            cartDto = new CartDTO()
            {
                Created    = DateTime.Today,
                CustomerId = customerId,
                Modified   = DateTime.Today,
                Id         = cart.Id,
                Products   = cart.Products.ToList()
            };
            this.cartRepository.Create(cartDto);
            this.cartRepository.Save();

            return(cartDto);
        }