예제 #1
0
        public async Task <IFluentAccountReceivable> UpdateAccountReceivableByInvoiceView(InvoiceView invoiceView)
        {
            try
            {
                Invoice invoice = await unitOfWork.invoiceRepository.GetEntityByInvoiceDocument(invoiceView.InvoiceDocument);

                Decimal?totalInvoiceAmount = await unitOfWork.invoiceRepository.GetInvoicedAmountByPurchaseOrderId(invoiceView.PurchaseOrderId);


                if (invoice != null)
                {
                    long?invoiceId = invoice.InvoiceId;

                    AccountReceivable acctRecLookup = await unitOfWork.accountReceivableRepository.GetEntityByPurchaseOrderId(invoice.PurchaseOrderId);

                    if (acctRecLookup != null)
                    {
                        //decimal ? totalInvoiceAmount = listInvoiceTasks.Result.Sum<Invoice>(e => e.Amount);

                        acctRecLookup.OpenAmount   = acctRecLookup.Amount - totalInvoiceAmount;
                        acctRecLookup.DebitAmount  = 0;
                        acctRecLookup.CreditAmount = totalInvoiceAmount;

                        UpdateAccountReceivable(acctRecLookup);
                        return(this as IFluentAccountReceivable);
                    }
                }
                processStatus = CreateProcessStatus.AlreadyExists;
                return(this as IFluentAccountReceivable);
            }
            catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); }
        }
예제 #2
0
        public IFluentAddressBook AddAddressBook(CustomerView customerView)
        {
            try
            {
                Task <AddressBook> lookupAddressBookTask = Task.Run(async() => await unitOfWork.addressBookRepository.GetAddressBookByCustomerView(customerView));
                Task.WaitAll(lookupAddressBookTask);
                if (lookupAddressBookTask.Result == null)
                {
                    AddressBook addressBook = new AddressBook();


                    applicationViewFactory.MapAddressBookEntity(ref addressBook, customerView);
                    AddAddressBook(addressBook);

                    return(this as IFluentAddressBook);
                }

                processStatus = CreateProcessStatus.AlreadyExists;
                return(this as IFluentAddressBook);
            }
            catch (Exception ex)
            {
                throw new Exception(GetMyMethodName(), ex);
            }
        }
예제 #3
0
        public IFluentPackingSlipDetail CreatePackingSlipDetailsByView(PackingSlipView view)
        {
            try
            {
                Task <PackingSlip> packingSlipTask = Task.Run(async() => await unitOfWork.packingSlipRepository.GetEntityBySlipDocument(view.SlipDocument));
                if (packingSlipTask.Result != null)
                {
                    long packingSlipId = view.PackingSlipId;

                    //TODO - send a list of ids and return back the views
                    foreach (var detailView in view.PackingSlipDetailViews)
                    {
                        detailView.PackingSlipId = packingSlipId;

                        PackingSlipDetail newDetail = new PackingSlipDetail();


                        newDetail = MapToEntity(detailView);

                        Task <IList <PackingSlipDetail> > listTask = Task.Run(async() => await unitOfWork.packingSlipDetailRepository.FindByExpression(e => e.ItemId == detailView.ItemId && e.PackingSlipId == newDetail.PackingSlipId));
                        Task.WaitAll(listTask);

                        if (listTask.Result == null)
                        {
                            //_dbContext.Set<PackingSlipDetail>().Add(newDetail);
                            AddPackingSlipDetail(newDetail);
                            return(this as IFluentPackingSlipDetail);
                        }
                    }
                }
                processStatus = CreateProcessStatus.AlreadyExists;
                return(this as IFluentPackingSlipDetail);
            }
            catch (Exception ex) { throw new Exception("CreatePackingSlipDetailsByView", ex); }
        }
예제 #4
0
        public IFluentProjectManagementProject UpdateProject(ProjectManagementProject updateProject)
        {
            unitOfWork.projectManagementProjectRepository.UpdateObject(updateProject);
            processStatus = CreateProcessStatus.Update;

            return(this as IFluentProjectManagementProject);
        }
예제 #5
0
        public IFluentProjectManagementProject DeleteProject(ProjectManagementProject deleteProject)
        {
            unitOfWork.projectManagementProjectRepository.DeleteObject(deleteProject);
            processStatus = CreateProcessStatus.Delete;

            return(this as IFluentProjectManagementProject);
        }
예제 #6
0
        public IFluentEmail CreateCustomerEmail(CustomerView customerView)
        {
            Task <AddressBook> lookupAddressBookTask = Task.Run(() => unitOfWork.addressBookRepository.GetAddressBookByCustomerView(customerView));

            Task.WaitAll(lookupAddressBookTask);
            customerView.AddressId = lookupAddressBookTask.Result.AddressId;

            if (customerView.AddressId > 0)
            {
                EmailEntity emailEntity = new EmailEntity();
                emailEntity.AddressId  = customerView.AddressId;
                emailEntity.Email      = customerView.AccountEmail;
                emailEntity.LoginEmail = customerView.AccountEmailLogin;
                emailEntity.Password   = customerView.AccountEmailPassword;

                AddEmail(emailEntity);
                processStatus = CreateProcessStatus.Insert;
            }
            else
            {
                processStatus = CreateProcessStatus.Failed;
            }

            return(this as IFluentEmail);
        }
예제 #7
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);
            }
        }
예제 #8
0
        public IFluentSupplierInvoice CreateSupplierInvoiceByView(SupplierInvoiceView view)
        {
            decimal amount = 0;

            try
            {
                //check if packing slip exists

                Task <SupplierInvoice> supplierInvoiceLookupTask = Task.Run(async() => await unitOfWork.supplierInvoiceRepository.GetEntityByNumber(view.SupplierInvoiceNumber));
                Task.WaitAll(supplierInvoiceLookupTask);

                if (supplierInvoiceLookupTask.Result != null)
                {
                    processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentSupplierInvoice);
                }


                foreach (var detail in view.SupplierInvoiceDetailViews)
                {
                    amount += detail.ExtendedCost ?? 0;
                }
                view.Amount = amount;


                SupplierInvoice supplierInvoice = MapToEntity(view);
                // applicationViewFactory.MapSupplierInvoiceEntity(ref supplierInvoice, view);

                AddSupplierInvoice(supplierInvoice);

                return(this as IFluentSupplierInvoice);
            }
            catch (Exception ex) { throw new Exception("CreateSupplierInvoiceByView", ex); }
        }
예제 #9
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); }
        }
예제 #10
0
        public IFluentPackingSlip CreatePackingSlipByView(PackingSlipView view)
        {
            decimal amount = 0;

            try
            {
                Task <PackingSlip> packingSlipTask = Task.Run(async() => await unitOfWork.packingSlipRepository.GetEntityBySlipDocument(view.SlipDocument));
                Task.WaitAll(packingSlipTask);


                if (packingSlipTask.Result != null)
                {
                    processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentPackingSlip);
                }


                foreach (var detail in view.PackingSlipDetailViews)
                {
                    amount += detail.ExtendedCost ?? 0;
                }
                view.Amount = amount;

                PackingSlip packingSlip = null;

                packingSlip = MapToEntity(view);

                AddPackingSlip(packingSlip);

                return(this as IFluentPackingSlip);
            }
            catch (Exception ex) { throw new Exception("CreatePackingSlipByView", ex); }
        }
예제 #11
0
        public IFluentProjectManagementProject AddProject(ProjectManagementProject newProject)
        {
            unitOfWork.projectManagementProjectRepository.AddObject(newProject);
            processStatus = CreateProcessStatus.Insert;

            return(this as IFluentProjectManagementProject);
        }
예제 #12
0
        public IFluentInventory CreateInventoryByPackingSlipView(PackingSlipView view)
        {
            int count = 0;

            try
            {
                foreach (var item in view.PackingSlipDetailViews)
                {
                    Task <Inventory> inventoryTask = Task.Run(async() => await unitOfWork.inventoryRepository.FindEntityByExpression(e => e.ItemId == item.ItemId && e.PackingSlipDetailId == item.PackingSlipDetailId));
                    Task.WaitAll(inventoryTask);
                    if (inventoryTask.Result == null)
                    {
                        Inventory inventory = new Inventory();

                        applicationViewFactory.MapPackingSlipIntoInventoryEntity(ref inventory, item);

                        AddInventory(inventory);
                        count++;
                    }
                }
                if (count == 0)
                {
                    processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentInventory);
                }
                else
                {
                    return(this as IFluentInventory);
                }
            }
            catch (Exception ex) { throw new Exception("CreateInventoryByPackingSlipView", ex); }
        }
예제 #13
0
 public ISupplier UpdateAccountsPayable(GeneralLedgerView generalLedgerView)
 {
     Task<CreateProcessStatus> statusResultTask = Task.Run(() => unitOfWork.accountPayableRepository.UpdatePayableByLedgerView(generalLedgerView));
     Task.WaitAll(statusResultTask);
     processStatus = statusResultTask.Result;
     return this as ISupplier;
 }
예제 #14
0
        public ICustomer CreateCustomerEmail(CustomerView customerView)
        {
            Task <AddressBook> lookupAddressBookTask = Task.Run(() => unitOfWork.addressBookRepository.GetAddressBookByCustomerView(customerView));

            Task.WaitAll(lookupAddressBookTask);
            customerView.AddressId = lookupAddressBookTask.Result.AddressId;

            if (customerView.AddressId > 0)
            {
                EmailView emailView = new EmailView();
                emailView.AddressId  = customerView.AddressId;
                emailView.EmailText  = customerView.AccountEmail.EmailText;
                emailView.LoginEmail = customerView.AccountEmail.LoginEmail;
                emailView.Password   = customerView.AccountEmail.Password;

                Task <CreateProcessStatus> resultTask = Task.Run(() => unitOfWork.emailRepository.CreateEmail(emailView));
                processStatus = resultTask.Result;
            }
            else
            {
                processStatus = CreateProcessStatus.Failed;
            }

            return(this as ICustomer);
        }
예제 #15
0
        public IFluentSupplierInvoiceDetail CreateSupplierInvoiceDetailsByView(SupplierInvoiceView view)
        {
            Task <SupplierInvoice> supplierInvoiceTask = Task.Run(async() => await unitOfWork.supplierInvoiceRepository.GetEntityByNumber(view.SupplierInvoiceNumber));

            Task.WaitAll(supplierInvoiceTask);


            if (supplierInvoiceTask.Result != null)
            {
                long supplierInvoiceId = supplierInvoiceTask.Result.SupplierInvoiceId;

                List <SupplierInvoiceDetail> list = new List <SupplierInvoiceDetail>();

                foreach (var detailView in view.SupplierInvoiceDetailViews)
                {
                    detailView.SupplierInvoiceId = supplierInvoiceId;

                    SupplierInvoiceDetail newDetail = MapToEntity(detailView);

                    list.Add(newDetail);
                }
                AddSupplierInvoiceDetails(list);
                processStatus = CreateProcessStatus.Insert;
                return(this as IFluentSupplierInvoiceDetail);
            }
            processStatus = CreateProcessStatus.Failed;
            return(this as IFluentSupplierInvoiceDetail);
        }
예제 #16
0
        public ITimeAndAttendanceScheduledToWork AddScheduledToWork(IList <TimeAndAttendanceScheduledToWork> items)
        {
            Task <CreateProcessStatus> resultTask = Task.Run(async() => await unitOfWork.timeAndAttendanceScheduledToWorkRepository.AddScheduledToWorkItems(items));

            Task.WaitAll(resultTask);
            processStatus = resultTask.Result;
            return(this as ITimeAndAttendanceScheduledToWork);
        }
        public ITimeAndAttendanceSchedule AddSchedule(TimeAndAttendanceScheduleView view)
        {
            Task <CreateProcessStatus> statusTask = Task.Run(async() => await unitOfWork.timeAndAttendanceScheduleRepository.AddSchedule(view));

            Task.WaitAll(statusTask);
            processStatus = statusTask.Result;
            return(this as ITimeAndAttendanceSchedule);
        }
예제 #18
0
        public IInvoiceDetail CreateInvoiceDetails(InvoiceView invoiceView)
        {
            Task <CreateProcessStatus> resultTask = Task.Run(() => unitOfWork.invoiceDetailRepository.CreateInvoiceDetailsByView(invoiceView));

            Task.WaitAll(resultTask);
            processStatus = resultTask.Result;
            return(this as IInvoiceDetail);
        }
예제 #19
0
        public IPurchaseOrder CreatePurchaseOrderDetails(PurchaseOrderView purchaseOrderView)
        {
            Task <CreateProcessStatus> resultTask = Task.Run(() => unitOfWork.purchaseOrderRepository.CreatePurchaseOrderDetailsByView(purchaseOrderView));

            Task.WaitAll(resultTask);
            processStatus = resultTask.Result;
            return(this as IPurchaseOrder);
        }
예제 #20
0
        public IPurchaseOrder CreateAcctPayByPurchaseOrderNumber(PurchaseOrderView purchaseOrderView)
        {
            Task <CreateProcessStatus> resultTask = Task.Run(() => unitOfWork.accountPayableRepository.CreateAcctPayByPurchaseOrderView(purchaseOrderView));

            Task.WaitAll(resultTask);
            processStatus = resultTask.Result;
            return(this as IPurchaseOrder);
        }
예제 #21
0
        public ICustomer CreateAddressBook(CustomerView customerView)
        {
            Task <CreateProcessStatus> statusTask = Task.Run(() => unitOfWork.addressBookRepository.CreateAddressBook(customerView));

            Task.WaitAll(statusTask);
            processStatus = statusTask.Result;
            return(this as ICustomer);
        }
예제 #22
0
        public IFluentInventory AddInventory(Inventory inventory)
        {
            unitOfWork.inventoryRepository.AddObject(inventory);

            this.processStatus = CreateProcessStatus.Insert;

            return(this as IFluentInventory);
        }
예제 #23
0
        public IAccountsReceivable CreateAcctRecFromInvoice(InvoiceView invoiceView)
        {
            Task <CreateProcessStatus> resultTask = Task.Run(() => unitOfWork.accountReceiveableRepository.CreateAcctRecFromInvoice(invoiceView));

            Task.WaitAll(resultTask);
            processStatus = resultTask.Result;
            return(this as IAccountsReceivable);
        }
예제 #24
0
        public IPackingSlip CreatePackingSlipDetails(PackingSlipView packingSlipView)
        {
            Task <CreateProcessStatus> resultTask = Task.Run(() => unitOfWork.packingSlipRepository.CreatePackingSlipDetailsByView(packingSlipView));

            Task.WaitAll(resultTask);
            processStatus = resultTask.Result;
            return(this as IPackingSlip);
        }
예제 #25
0
 public IFluentTimeAndAttendanceSetup UpdateTimeAndAttendanceSetups(IList <TimeAndAttendanceSetup> newObjects)
 {
     foreach (var item in newObjects)
     {
         unitOfWork.timeAndAttendanceSetupRepository.UpdateObject(item);
     }
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentTimeAndAttendanceSetup);
 }
예제 #26
0
 public IFluentSupplierLedger UpdateSupplierLedgers(IList <SupplierLedger> newObjects)
 {
     foreach (var item in newObjects)
     {
         unitOfWork.supplierLedgerRepository.UpdateObject(item);
     }
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentSupplierLedger);
 }
예제 #27
0
 public IFluentEquipment UpdateEquipments(IList <Equipment> newObjects)
 {
     foreach (var item in newObjects)
     {
         unitOfWork.equipmentRepository.UpdateObject(item);
     }
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentEquipment);
 }
예제 #28
0
 public IFluentPhone UpdatePhoness(IList <PhoneEntity> newObjects)
 {
     foreach (var item in newObjects)
     {
         unitOfWork.phoneRepository.UpdateObject(item);
     }
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentPhone);
 }
예제 #29
0
 public IFluentScheduleEvent UpdateScheduleEvents(IList <ScheduleEvent> newObjects)
 {
     foreach (var item in newObjects)
     {
         unitOfWork.scheduleEventRepository.UpdateObject(item);
     }
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentScheduleEvent);
 }
예제 #30
0
 public IFluentSupplierInvoiceDetail UpdateSupplierInvoiceDetails(IList <SupplierInvoiceDetail> newObjects)
 {
     foreach (var item in newObjects)
     {
         unitOfWork.supplierInvoiceDetailRepository.UpdateObject(item);
     }
     this.processStatus = CreateProcessStatus.Update;
     return(this as IFluentSupplierInvoiceDetail);
 }