public void Test_SiteManagementService_AddFactorys()
        {
            FactoryDto[]    dtos            = new FactoryDto[3];
            OperationResult operationResult = new OperationResult(OperationResultType.Success);

            _factoryRepository.Insert(dtos).ReturnsForAnyArgs(operationResult);
            _siteManagementService.FactoryRepository.Returns(_factoryRepository);
            Assert.AreEqual(_siteManagementService.AddFactorys(dtos), operationResult);
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Put(int id, [FromBody] FactoryDto factory)
        {
            var factoryUpdate = await _factoryRepository.Get(id);

            if (factoryUpdate == null)
            {
                return(NotFound());
            }
            _mapper.Map(factory, factoryUpdate);
            await _factoryRepository.Update(id, factoryUpdate);

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <ActionResult <FactoryDto> > Create(FactoryDto factoryDto)
        {
            var factory       = _mapper.Map <Factory>(factoryDto);
            var validationRes = _validator.Validate(factory);

            if (!validationRes.IsValid)
            {
                return(BadRequest(new { errors = validationRes.Errors }));
            }
            var res = await _factoryRepository.Create(factory);

            return(CreatedAtAction(nameof(Get), new { Id = factory.Id }, factory));
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            #region 工厂模式
            FactoryDto.Print();
            #endregion

            //VolatileYield.Print();
            //VolatileYield.Print1();

            //InterLockedParallel.Print();
            //InterLockedParallel.Print1();

            #region 简单工厂模式
            //FoodDto food = SimpleFactoryDto.CreateFood("FoodA");
            //food.Print();

            //FoodDto foodb = SimpleFactoryDto.CreateFood("FoodB");
            //foodb.Print();
            #endregion

            //ArrayList_List.Copy();
        }