コード例 #1
0
ファイル: BillService.cs プロジェクト: ximemou/EveryPay-Obl
        private void validateTansactionIsNotAlreadyRegistered(int billId, List <SpecificFieldValueDTO> values)
        {
            bool matches = true;

            if (unitOfWork.SpecificFieldValueRepository.Get().Count() > 0)
            {
                Bill bill = unitOfWork.BillRepository.GetByID(billId);
                for (int i = 0; i < values.Count && matches; i++)
                {
                    SpecificFieldValueDTO            specificFieldValue = values[i];
                    IEnumerable <SpecificFieldValue> possibleMatches    = unitOfWork.SpecificFieldValueRepository.Get
                                                                              (s => s.Value == specificFieldValue.Value && s.SupplierFieldId == specificFieldValue.IdSupplierField && s.Bill.Amount == bill.Amount);

                    if (possibleMatches.Count() == 0)
                    {
                        matches = false;
                    }
                }

                if (matches)
                {
                    throw new PaymentAlreadyRegisteredException("Ya existe una factura con esos datos");
                }
            }
        }
コード例 #2
0
ファイル: BillService.cs プロジェクト: ximemou/EveryPay-Obl
        private SpecificFieldValue ConvertDTO(SpecificFieldValueDTO valueDTO)
        {
            SupplierField supplierField = unitOfWork.SupplierFieldRepository.Get(s => s.SupplierFieldId == valueDTO.IdSupplierField).FirstOrDefault();

            if (supplierField != null)
            {
                SpecificFieldValue specificValue = new SpecificFieldValue();
                specificValue.Value         = valueDTO.Value;
                specificValue.Supplierfield = supplierField;
                return(specificValue);
            }
            else
            {
                throw new NotFoundException("No existe el campo de proveedor especificado");
            }
        }
コード例 #3
0
ファイル: BillService.cs プロジェクト: ximemou/EveryPay-Obl
        public bool ValidateExistsBillForTheSupplier(int billId, List <SpecificFieldValueDTO> values)
        {
            bool wrong = false;

            for (int i = 0; i < values.Count && !wrong; i++)
            {
                SpecificFieldValueDTO specificValue = values[i];

                SupplierField supplierField = unitOfWork.SupplierFieldRepository.GetByID(specificValue.IdSupplierField);
                Supplier      supplier      = unitOfWork.SupplierRepository.GetByID(supplierField.SupplierId);

                if (unitOfWork.BillSupplierRepository.Get(b => b.BillId == billId && b.SupplierId == supplier.SupplierId) == null)
                {
                    wrong = true;
                }
            }
            return(wrong);
        }