Ejemplo n.º 1
0
        public async Task <CreateProcessStatus> CreateLedgerFromView(CustomerLedgerView view)
        {
            try
            {
                CustomerLedger customerLedger = new CustomerLedger();

                var query = await(from e in _dbContext.CustomerLedgers
                                  where e.AccountId == view.AccountId &&
                                  e.Amount == view.Amount &&
                                  e.GLDate == view.GLDate &&
                                  e.DocNumber == view.DocNumber &&
                                  e.Comment == view.Comment

                                  select e
                                  ).FirstOrDefaultAsync <CustomerLedger>();

                if (query == null)
                {
                    applicationViewFactory.MapCustomerLedgerEntity(ref customerLedger, view);


                    AddObject(customerLedger);

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

                CustomerLedgerView view = applicationViewFactory.MapCustomerLedgerView(query);
                return(view);
            }
            catch (Exception ex)
            { throw new Exception(GetMyMethodName(), ex); }
        }