Ejemplo n.º 1
0
 public Income(string name, decimal amount, DateTime date, Wash wash = null)
     : base(name, amount, date)
 {
     Wash = wash;
     if (wash != null)
     {
         WashId = wash.Id;
     }
 }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
        }