Esempio n. 1
0
        public async Task <CreateProcessStatus> CreateSupplierLedgerFromView(SupplierLedgerView view)
        {
            try
            {
                SupplierLedger supplierLedger = new SupplierLedger();

                var query = await(from e in _dbContext.SupplierLedgers
                                  where e.AccountId == view.AccountId &&
                                  e.Amount == view.Amount &&
                                  e.GLDate == view.GLDate &&
                                  e.DocNumber == view.DocNumber
                                  select e
                                  ).FirstOrDefaultAsync <SupplierLedger>();

                if (query == null)
                {
                    applicationViewFactory.MapSupplierLedgerEntity(ref supplierLedger, view);


                    AddObject(supplierLedger);

                    return(CreateProcessStatus.Insert);
                }
                return(CreateProcessStatus.AlreadyExists);
            }
            catch (Exception ex)
            { throw new Exception(GetMyMethodName(), ex); }
        }
Esempio n. 2
0
        public async Task <SupplierLedgerView> GetSupplierLedgerByDocNumber(long?docNumber, string docType)
        {
            try
            {
                var query = await(from a in _dbContext.SupplierLedgers
                                  where a.DocNumber == docNumber &&
                                  a.DocType == docType
                                  select a).FirstOrDefaultAsync <SupplierLedger>();

                SupplierLedgerView view = applicationViewFactory.MapSupplierLedgerView(query);
                return(view);
            }
            catch (Exception ex)
            { throw new Exception(GetMyMethodName(), ex); }
        }
Esempio n. 3
0
        public async Task <CreateProcessStatus> UpdateSupplierLedger(SupplierLedgerView supplierLedgerView)
        {
            try
            {
                var query = await GetObjectAsync(supplierLedgerView.SupplierLedgerId);

                SupplierLedger supplierLedgerBase = query;

                if (query != null)
                {
                    applicationViewFactory.MapSupplierLedgerEntity(ref supplierLedgerBase, supplierLedgerView);
                    UpdateObject(supplierLedgerBase);
                    return(CreateProcessStatus.Update);
                }
                return(CreateProcessStatus.Failed);
            }
            catch (Exception ex)
            {
                throw new Exception(GetMyMethodName(), ex);
            }
        }