public async Task <IActionResult> DeleteContractInvoice([FromBody] ContractInvoiceView view)
        {
            ContractInvoiceModule invMod          = new ContractInvoiceModule();
            ContractInvoice       contractInvoice = await invMod.ContractInvoice.Query().MapToEntity(view);

            invMod.ContractInvoice.DeleteContractInvoice(contractInvoice).Apply();

            return(Ok(view));
        }
        public async Task <IActionResult> UpdateContractInvoice([FromBody] ContractInvoiceView view)
        {
            ContractInvoiceModule invMod = new ContractInvoiceModule();

            ContractInvoice contractInvoice = await invMod.ContractInvoice.Query().MapToEntity(view);


            invMod.ContractInvoice.UpdateContractInvoice(contractInvoice).Apply();

            ContractInvoiceView retView = await invMod.ContractInvoice.Query().GetViewById(contractInvoice.ContractInvoiceId);


            return(Ok(retView));
        }
        public async Task <IActionResult> AddContractInvoice([FromBody] ContractInvoiceView view)
        {
            ContractInvoiceModule invMod = new ContractInvoiceModule();

            NextNumber nnContractInvoice = await invMod.ContractInvoice.Query().GetNextNumber();

            view.ContractInvoiceNumber = nnContractInvoice.NextNumberValue;

            ContractInvoice contractInvoice = await invMod.ContractInvoice.Query().MapToEntity(view);

            invMod.ContractInvoice.AddContractInvoice(contractInvoice).Apply();

            ContractInvoiceView newView = await invMod.ContractInvoice.Query().GetViewByNumber(view.ContractInvoiceNumber);


            return(Ok(newView));
        }
Beispiel #4
0
        public async Task TestAddUpdatDelete()
        {
            ContractInvoiceModule ContractInvoiceMod = new ContractInvoiceModule();
            Contract contract = await ContractInvoiceMod.Contract.Query().GetEntityById(1);

            Invoice invoice = await ContractInvoiceMod.Invoice.Query().GetEntityById(5);

            ContractInvoiceView view = new ContractInvoiceView()
            {
                ContractId = contract.ContractId,
                InvoiceId  = invoice.InvoiceId
            };
            NextNumber nnNextNumber = await ContractInvoiceMod.ContractInvoice.Query().GetNextNumber();

            view.ContractInvoiceNumber = nnNextNumber.NextNumberValue;

            ContractInvoice contractInvoice = await ContractInvoiceMod.ContractInvoice.Query().MapToEntity(view);

            ContractInvoiceMod.ContractInvoice.AddContractInvoice(contractInvoice).Apply();

            ContractInvoice newContractInvoice = await ContractInvoiceMod.ContractInvoice.Query().GetEntityByNumber(view.ContractInvoiceNumber);

            Assert.NotNull(newContractInvoice);

            newContractInvoice.InvoiceId = 8;

            ContractInvoiceMod.ContractInvoice.UpdateContractInvoice(newContractInvoice).Apply();

            ContractInvoiceView updateView = await ContractInvoiceMod.ContractInvoice.Query().GetViewById(newContractInvoice.ContractInvoiceId);

            if (updateView.InvoiceId != 8)
            {
                Assert.True(false);
            }
            ContractInvoiceMod.ContractInvoice.DeleteContractInvoice(newContractInvoice).Apply();
            ContractInvoice lookupContractInvoice = await ContractInvoiceMod.ContractInvoice.Query().GetEntityById(view.ContractInvoiceId);

            Assert.Null(lookupContractInvoice);
        }
 public IFluentContractInvoice DeleteContractInvoice(ContractInvoice deleteObject)
 {
     unitOfWork.contractInvoiceRepository.DeleteObject(deleteObject);
     this.processStatus = CreateProcessStatus.Delete;
     return(this as IFluentContractInvoice);
 }
 public IFluentContractInvoice AddContractInvoice(ContractInvoice newObject)
 {
     unitOfWork.contractInvoiceRepository.AddObject(newObject);
     this.processStatus = CreateProcessStatus.Insert;
     return(this as IFluentContractInvoice);
 }
Beispiel #7
0
        public async Task TestObserver()
        {
            InvoiceModule         invMod             = new InvoiceModule();
            ContractInvoiceModule contractInvoiceMod = new ContractInvoiceModule();

            Customer customer = await invMod.Customer.Query().GetEntityById(9);

            AddressBook addressBookCustomer = await invMod.AddressBook.Query().GetEntityById(customer?.AddressId);

            NextNumber nextNumber = await invMod.Invoice.Query().GetNextNumber();

            TaxRatesByCode taxRatesByCode = await invMod.TaxRatesByCode.Query().GetEntityById(1);

            InvoiceView invoiceView = new InvoiceView();

            invoiceView.InvoiceDocument  = "Inv-99";
            invoiceView.InvoiceDate      = DateTime.Parse("8/10/2018");
            invoiceView.Amount           = 1500.0M;
            invoiceView.CustomerId       = customer?.CustomerId;
            invoiceView.CustomerName     = addressBookCustomer?.Name;
            invoiceView.Description      = "VNW Fixed Asset project";
            invoiceView.PaymentTerms     = "Net 30";
            invoiceView.TaxAmount        = 0;
            invoiceView.CompanyId        = 1;
            invoiceView.TaxRatesByCodeId = taxRatesByCode.TaxRatesByCodeId;

            invoiceView.InvoiceNumber = nextNumber.NextNumberValue;

            Invoice newInvoice = await invMod.Invoice.Query().MapToEntity(invoiceView);

            Observer mediator = new Observer();

            mediator.SubscribeToObserver(invMod, invMod.MessageFromObserver);
            mediator.SubscribeToObserver(contractInvoiceMod, contractInvoiceMod.MessageFromObserver);


            IObservableAction observedAction = new ObservableAction();

            MessageAction action = new MessageAction {
                targetByName = nameof(Invoice), command_action = TypeOfObservableAction.InsertData, Invoice = newInvoice
            };

            observedAction.Actions.Add(action);

            NextNumber nextNumberContractInvoice = await invMod.ContractInvoice.Query().GetNextNumber();

            ContractInvoiceView contractInvoiceView = new ContractInvoiceView
            {
                InvoiceId             = 5,
                ContractId            = 1,
                ContractInvoiceNumber = nextNumberContractInvoice.NextNumberValue
            };

            ContractInvoice contractInvoice = await invMod.ContractInvoice.Query().MapToEntity(contractInvoiceView);

            MessageAction actionContractInvoice = new MessageAction {
                targetByName = nameof(ContractInvoice), command_action = TypeOfObservableAction.InsertData, ContractInvoice = contractInvoice
            };

            observedAction.Actions.Add(actionContractInvoice);

            mediator.TransmitMessage(observedAction);

            if (observedAction.Actions.Count() > 0)
            {
                Assert.True(false);
            }

            Invoice lookupInvoice = await invMod.Invoice.Query().GetEntityByNumber(invoiceView.InvoiceNumber);

            lookupInvoice.Amount = 9999;

            ContractInvoice lookupContractInvoice = await contractInvoiceMod.ContractInvoice.Query().GetEntityByNumber(contractInvoiceView.ContractInvoiceNumber);


            //*******Contract Invoice


            MessageAction actionInvoiceUpdate = new MessageAction
            {
                targetByName   = nameof(Invoice),
                command_action = TypeOfObservableAction.UpdateData,
                Invoice        = lookupInvoice
            };

            observedAction.Actions.Add(actionInvoiceUpdate);

            MessageAction actionInvoiceDelete = new MessageAction
            {
                targetByName   = nameof(Invoice),
                command_action = TypeOfObservableAction.DeleteData,
                Invoice        = lookupInvoice
            };

            observedAction.Actions.Add(actionInvoiceDelete);

            MessageAction actionContractInvoiceDelete = new MessageAction
            {
                targetByName    = nameof(ContractInvoice),
                command_action  = TypeOfObservableAction.DeleteData,
                ContractInvoice = lookupContractInvoice
            };

            observedAction.Actions.Add(actionContractInvoiceDelete);

            mediator.TransmitMessage(observedAction);

            if (observedAction.Actions.Count() > 0)
            {
                Assert.True(false);
            }

            await Task.Yield();

            Assert.True(true);
        }