Пример #1
0
        private SupplierLedger MapToEntity(SupplierLedgerView inputObject)
        {
            Mapper         mapper    = new Mapper();
            SupplierLedger outObject = mapper.Map <SupplierLedger>(inputObject);

            return(outObject);
        }
Пример #2
0
        public IFluentSupplierLedger UpdateEntityByView(SupplierLedgerView supplierLedgerView)

        {
            try
            {
                Task <SupplierLedger> supplierLedgerBaseTask = Task.Run(async() => await unitOfWork.supplierLedgerRepository.GetEntityById(supplierLedgerView.SupplierLedgerId));
                Task.WaitAll(supplierLedgerBaseTask);
                SupplierLedger supplierLedgerBase = supplierLedgerBaseTask.Result;


                if (supplierLedgerBase != null)

                {
                    applicationViewFactory.MapSupplierLedgerEntity(ref supplierLedgerBase, supplierLedgerView);
                    UpdateSupplierLedger(supplierLedgerBase);

                    processStatus = CreateProcessStatus.Update;
                    return(this as IFluentSupplierLedger);
                }

                processStatus = CreateProcessStatus.Failed;
                return(this as IFluentSupplierLedger);
            }
            catch (Exception ex)
            {
                throw new Exception("UpdateEntityByView", ex);
            }
        }
Пример #3
0
        public IFluentSupplierLedger CreateEntityByView(SupplierLedgerView view)
        {
            try
            {
                //SupplierLedger supplierLedger = new SupplierLedger();

                Task <SupplierLedger> supplierLedgerQueryTask = Task.Run(async() => await unitOfWork.supplierLedgerRepository.GetEntityByView(view));
                Task.WaitAll(supplierLedgerQueryTask);


                if (supplierLedgerQueryTask.Result == null)
                {
                    SupplierLedger supplierLedger = MapToEntity(view);


                    AddSupplierLedger(supplierLedger);

                    processStatus = CreateProcessStatus.Insert;

                    return(this as IFluentSupplierLedger);
                }
                processStatus = CreateProcessStatus.AlreadyExists;
                return(this as IFluentSupplierLedger);
            }
            catch (Exception ex)
            { throw new Exception("CreateEntityByView", ex); }
        }
Пример #4
0
        public async Task TestAddUpdatDelete()
        {
            SupplierLedgerModule SupplierLedgerMod = new SupplierLedgerModule();
            Supplier             supplier          = await SupplierLedgerMod.Supplier.Query().GetEntityById(3);

            Invoice invoice = await SupplierLedgerMod.Invoice.Query().GetEntityById(2);

            AccountPayable accountPayable = await SupplierLedgerMod.AccountPayable.Query().GetEntityById(2);

            GeneralLedger generalLedger = await SupplierLedgerMod.GeneralLedger.Query().GetEntityById(17);

            AddressBook addressBook = await SupplierLedgerMod.AddressBook.Query().GetEntityById(17);


            SupplierLedgerView view = new SupplierLedgerView()
            {
                SupplierId      = supplier.SupplierId,
                InvoiceId       = invoice.InvoiceId,
                AcctPayId       = accountPayable.AccountPayableId,
                Amount          = 300M,
                Gldate          = DateTime.Parse("11/11/2019"),
                AccountId       = generalLedger.AccountId,
                GeneralLedgerId = generalLedger.GeneralLedgerId,
                DocNumber       = 17,
                Comment         = "back to school",
                AddressId       = addressBook.AddressId,
                CreatedDate     = DateTime.Parse("11/11/2019"),
                DocType         = "PV",
                DebitAmount     = null,
                CreditAmount    = null,
                FiscalYear      = 2019,
                FiscalPeriod    = 11
            };
            NextNumber nnNextNumber = await SupplierLedgerMod.SupplierLedger.Query().GetNextNumber();

            view.SupplierLedgerNumber = nnNextNumber.NextNumberValue;

            SupplierLedger supplierLedger = await SupplierLedgerMod.SupplierLedger.Query().MapToEntity(view);

            SupplierLedgerMod.SupplierLedger.AddSupplierLedger(supplierLedger).Apply();

            SupplierLedger newSupplierLedger = await SupplierLedgerMod.SupplierLedger.Query().GetEntityByNumber(view.SupplierLedgerNumber);

            Assert.NotNull(newSupplierLedger);

            newSupplierLedger.Comment = "back to school update";

            SupplierLedgerMod.SupplierLedger.UpdateSupplierLedger(newSupplierLedger).Apply();

            SupplierLedgerView updateView = await SupplierLedgerMod.SupplierLedger.Query().GetViewById(newSupplierLedger.SupplierLedgerId);

            Assert.Same(updateView.Comment, "back to school update");
            SupplierLedgerMod.SupplierLedger.DeleteSupplierLedger(newSupplierLedger).Apply();
            SupplierLedger lookupSupplierLedger = await SupplierLedgerMod.SupplierLedger.Query().GetEntityById(view.SupplierLedgerId);

            Assert.Null(lookupSupplierLedger);
        }
Пример #5
0
        public async Task <SupplierLedger> GetEntityByView(SupplierLedgerView view)
        {
            var query = await(from e in _dbContext.SupplierLedger
                              where e.AccountId == view.AccountId &&
                              e.Amount == view.Amount &&
                              e.Gldate == view.Gldate &&
                              e.DocNumber == view.DocNumber
                              select e
                              ).FirstOrDefaultAsync <SupplierLedger>();

            return(query);
        }
Пример #6
0
        public IFluentSupplierLedger UpdateSupplierLedgerWithGeneralLedger(GeneralLedgerView generalLedgerView)
        {
            Task <SupplierLedgerView> supplierLedgerTask = Task.Run(async() => await Query().GetSupplierLedgerByDocNumber(generalLedgerView.DocNumber, generalLedgerView.DocType));

            Task.WaitAll(supplierLedgerTask);

            SupplierLedgerView supplierLedgerView = applicationViewFactory.MapSupplierLedgerView(generalLedgerView);

            supplierLedgerView.SupplierLedgerId = supplierLedgerTask.Result.SupplierLedgerId;

            UpdateEntityByView(supplierLedgerView);
            Apply();

            return(this as IFluentSupplierLedger);
        }
Пример #7
0
        public IFluentSupplierLedger CreateSupplierLedgerWithGeneralLedgerView(GeneralLedgerView generalLedgerView)
        {
            Task <GeneralLedger> generalLedgerTask = Task.Run(() => unitOfWork.generalLedgerRepository.GetEntityByDocNumber(generalLedgerView.DocNumber, generalLedgerView.DocType));

            Task.WaitAll(generalLedgerTask);

            SupplierLedgerView supplierLedgerView = applicationViewFactory.MapSupplierLedgerView(generalLedgerView);

            supplierLedgerView.GeneralLedgerId = generalLedgerTask.Result.GeneralLedgerId;

            CreateEntityByView(supplierLedgerView);
            Apply();

            return(this as IFluentSupplierLedger);
        }