示例#1
0
文件: WashBll.cs 项目: Sp1n89/AutoDok
 public void Create(CreateWashEntity entity)
 {
     switch (entity.WashType)
     {
             case WashType.CarpetWash:
         {
             CreateCarpetWash(entity);
             break;
         }
             case WashType.ContractedCarWash:
         {
             CreateContractedCarWash(entity);
             break;
         }
             case WashType.IndividualCarWash:
         {
             CreateIndividualCarWash(entity);
             break;
         }
     }
 }
示例#2
0
文件: WashBll.cs 项目: Sp1n89/AutoDok
        private void CreateCarpetWash(CreateWashEntity entity)
        {
            if (!entity.Amount.HasValue)
            {
                throw new BusinessLayerException("Carpet wash has no amount.");
            }

            if (!entity.SquareArea.HasValue)
            {
                throw new BusinessLayerException("Carpet wash has no square area.");
            }

            var income = new Income(entity.WashType.Localize(), entity.Amount.Value, entity.Date);
            _operationRepository.Insert(income);

            var wash = new Wash(entity.Date, entity.SquareArea.Value, income);
            _washRepository.Insert(wash);

            income.Wash = wash;
            income.WashId = wash.Id;
            _operationRepository.Update(income);
        }
示例#3
0
文件: WashBll.cs 项目: Sp1n89/AutoDok
        private void CreateContractedCarWash(CreateWashEntity entity)
        {
            if (!entity.ContractId.HasValue)
            {
                throw new BusinessLayerException("Contracted Car wash has no amount.");
            }

            var contract = _contractRepository.GetById(entity.ContractId.Value);

            if (contract == null)
            {
                throw  new BusinessLayerException("Selected contract does not exist.");
            }

            var wash = new Wash(entity.Date, entity.CarNumber, contract);
            _washRepository.Insert(wash);

            contract.Washes.Add(wash);
            _contractRepository.Update(contract);
        }
示例#4
0
文件: WashBll.cs 项目: Sp1n89/AutoDok
        private void CreateIndividualCarWash(CreateWashEntity entity)
        {
            if (!entity.Amount.HasValue)
            {
                throw new BusinessLayerException("Individual Car wash has no amount.");
            }

            var income = new Income(entity.WashType.Localize(), entity.Amount.Value, entity.Date);

            var wash = new Wash(entity.Date, entity.CarNumber, income);
            _washRepository.Insert(wash);

            income.Wash = wash;
            income.WashId = wash.Id;
            _operationRepository.Insert(income);
        }