コード例 #1
0
        public async Task <GetStockItemDto> CreateStockItemAsync(CreateStockItemDto stockItemDto)
        {
            await CheckStockItemAsync(0, stockItemDto.Name, stockItemDto.TypeId, stockItemDto.UnitOfMeasureId, stockItemDto.ItemUnit);

            var stockItem = _mapper.Map <StockItem>(stockItemDto);

            stockItem = await _stockItem.AddStockItemAsync(stockItem);

            return(_mapper.Map <GetStockItemDto>(stockItem));
        }
コード例 #2
0
 public CreateStockItemDtoValidatorFixture()
 {
     Validator = new CreateStockItemDtoValidator();
     Model     = new CreateStockItemDto
     {
         TypeId          = 1,
         Name            = "Rice",
         ItemUnit        = 5,
         UnitOfMeasureId = 1,
         Description     = "Rice 5kg bag"
     };
 }
コード例 #3
0
        public StockItemRepositoryFixture()
        {
            MockStockItemService = new Mock <IStockItemService>();
            var unitOfMeasure1 = new UnitOfMeasure {
                Id = 1, Code = "kg", Description = ""
            };
            var unitOfMeasure2 = new UnitOfMeasure {
                Id = 2, Code = "g", Description = ""
            };
            var unitOfMeasure3 = new UnitOfMeasure {
                Id = 3, Code = "l", Description = ""
            };
            var unitOfMeasure4 = new UnitOfMeasure {
                Id = 4, Code = "ml", Description = ""
            };
            var unitOfMeasure5 = new UnitOfMeasure {
                Id = 5, Code = "none", Description = ""
            };

            var stockType1 = new StockType {
                Id = 1, Type = "Grocery"
            };
            var stockType2 = new StockType {
                Id = 2, Type = "Beverage"
            };
            var stockType3 = new StockType {
                Id = 3, Type = "Stationery"
            };

            StockItems = new List <StockItem>
            {
                new StockItem {
                    Id = 1, TypeId = 1, Type = stockType1, Name = "Rice", ItemUnit = 10, UnitOfMeasureId = 1, UnitOfMeasure = unitOfMeasure1
                },
                new StockItem {
                    Id = 2, TypeId = 1, Type = stockType1, Name = "Chilli Powder", ItemUnit = 250, UnitOfMeasureId = 2, UnitOfMeasure = unitOfMeasure2
                },
                new StockItem {
                    Id = 3, TypeId = 2, Type = stockType2, Name = "Water", ItemUnit = 1, UnitOfMeasureId = 3, UnitOfMeasure = unitOfMeasure3
                },
                new StockItem {
                    Id = 4, TypeId = 3, Type = stockType3, Name = "Blue Pen", ItemUnit = 1, UnitOfMeasureId = 5, UnitOfMeasure = unitOfMeasure5
                },
            };

            CollectionEnvelop = new CollectionEnvelop <StockItem>
            {
                Items        = StockItems.Where(d => d.TypeId == 1),
                ItemsPerPage = 10,
                TotalItems   = 2
            };

            CreateStockItemDto = new CreateStockItemDto
            {
                Name            = "Cream Soda",
                TypeId          = 2,
                UnitOfMeasureId = 4,
                ItemUnit        = 300
            };

            CreatedNewStockItem = new StockItem
            {
                Id              = 5,
                TypeId          = 2,
                Type            = stockType2,
                Name            = "Cream Soda",
                ItemUnit        = 300,
                UnitOfMeasureId = 4,
                UnitOfMeasure   = unitOfMeasure4
            };

            EditStockItemDto = new EditStockItemDto
            {
                TypeId          = 1,
                Name            = "Rice",
                ItemUnit        = 10,
                UnitOfMeasureId = 1,
                Description     = "10kg bag"
            };
        }
コード例 #4
0
        public async Task <IActionResult> CreateStockItem(CreateStockItemDto stockTypeDto, ApiVersion version)
        {
            var result = await _repository.CreateStockItemAsync(stockTypeDto);

            return(CreatedAtRoute(new { id = result.Id, version = $"{version}" }, result));
        }
コード例 #5
0
        public StockItemControllerFixture()
        {
            ApiVersion = new ApiVersion(1, 0);

            MockStockItemRepository = new Mock <IStockItemRepository>();

            StockItems = new List <GetStockItemDto>
            {
                new GetStockItemDto {
                    Id = 1, TypeId = 1, StockType = "Beverage", ItemUnit = 1.5m, UnitOfMeasureId = 1, UnitOfMeasureCode = "l", Name = "Coca-Cola", Description = ""
                },
                new GetStockItemDto {
                    Id = 2, TypeId = 1, StockType = "Beverage", ItemUnit = 300.0m, UnitOfMeasureId = 2, UnitOfMeasureCode = "ml", Name = "Coca-Cola", Description = ""
                },
                new GetStockItemDto {
                    Id = 3, TypeId = 2, StockType = "Grocery", ItemUnit = 10, UnitOfMeasureId = 3, UnitOfMeasureCode = "kg", Name = "Rice", Description = ""
                },
            };

            StockItemEnvelop = new StockItemEnvelop
            {
                StockItemCount = 2,
                StockItems     = StockItems.Where(d => d.TypeId == 1),
                ItemsPerPage   = 10,
                TotalPages     = 1
            };

            ValidCreateStockItemDto = new CreateStockItemDto
            {
                TypeId          = 2,
                Name            = "Sugar",
                ItemUnit        = 20,
                UnitOfMeasureId = 3,
                Description     = "test"
            };

            CreateStockItemDtoResult = new GetStockItemDto
            {
                Id                = 4,
                TypeId            = 2,
                StockType         = "Grocery",
                ItemUnit          = 20,
                UnitOfMeasureId   = 3,
                UnitOfMeasureCode = "kg",
                Name              = "Sugar",
                Description       = "test"
            };

            ValidEditStockItemDto = new EditStockItemDto
            {
                TypeId          = 1,
                ItemUnit        = 400.0m,
                UnitOfMeasureId = 2,
                Name            = "Coca-Cola",
                Description     = ""
            };

            EditStockItemDtoResult = new GetStockItemDto
            {
                Id                = 2,
                TypeId            = 1,
                StockType         = "Beverage",
                ItemUnit          = 400.0m,
                UnitOfMeasureId   = 2,
                UnitOfMeasureCode = "ml",
                Name              = "Coca-Cola",
                Description       = ""
            };
        }