Ejemplo n.º 1
0
        public void AddPaymentForEntity(DebitCreditOfPayment paymentInfo)
        {
            var mapper = new DebitCreditMapper();
            var entity = mapper.Map(paymentInfo);

            _debitCreditRepo.Add(entity);
            _debitCreditRepo.Save();
        }
        public DebitCreditOfPaymentViewModel(Entity entity)
        {
            _entity            = entity;
            SiteId             = _entity.SiteId;
            _repositoryManager = new RepositoryManager(new SqliteContext());
            PaymentToAdd       = new DebitCreditOfPayment();
            Add    = new RelayCommand(AddCommand);
            Search = new RelayCommand(SearchCommand);
            PaymentGridVisibility = Visibility.Hidden;
            EntityGridVisibility  = Visibility.Hidden;
            _entityTypes          = _repositoryManager.GetPaymentEntity().ToList();
            _paymentModes         = _repositoryManager.GetPaymentMode().ToList();
            EntityClick           = new RelayCommand(EntityClickCmd);

            EntityGridVisibility = Visibility.Visible;
            SetIdentity(_entity.EntityTypeId);
            _entities = new ObservableCollection <Entity>(new List <Entity> {
                _entity
            });
            SelectedEntity    = _entityTypes.Single(x => x.EntityTypeId == _entity.EntityTypeId);
            EntityGridHeading = SelectedEntity.EntityTypeName + " Detail";
            GetPaymentSummary();
        }
        private void AddCommand(object obj)
        {
            ErrorMessage = "";
            var payment = obj as DebitCreditOfPayment;

            payment.SiteId       = SiteId;
            payment.CreditAmount = CreditAmount;
            payment.DebitAmount  = DebitAmount;
            payment.EntityId     = _entity.EntityId;
            payment.EntityType   = EntityTypes.Single(x => x.EntityTypeId == _entity.EntityTypeId);

            if (payment.CreditAmount == 0 || payment.SelectedMode == null || payment.PaymentDate == default(DateTime))
            {
                ErrorMessage = "*Please check the entry. Some field's Values are missing.";
                return;
            }

            _repositoryManager.AddPaymentForEntity(payment);
            PaymentDetails = new ObservableCollection <DebitCreditOfPayment>(_repositoryManager.GetDebitCreditListOfEntity(_entity));
            PaymentToAdd   = new DebitCreditOfPayment();
            CreditAmount   = 0;
            DebitAmount    = payment.DebitAmount;
            AmountRemain   = DebitAmount;
        }