Exemplo n.º 1
0
        public async Task ProcessAccount(string json)
        {
            try
            {
                ChartOfAccount chartOfAcct = JsonConvert.DeserializeObject <ChartOfAccount>(json);

                Company company = await unitOfWork.companyRepository.GetEntityById(chartOfAcct.CompanyId);

                //chartOfAcct.Company = company;

                ChartOfAccountView view = await MapToView(chartOfAcct);

                IList <ChartOfAccount> list = await unitOfWork.chartOfAccountRepository.GetEntitiesByAccount(company.CompanyCode, view.BusUnit, view.ObjectNumber, view.Subsidiary);

                if (list.Count == 0)
                {
                    AddChartOfAccount(chartOfAcct);
                }
                else
                {
                    //foreach (var item in query)
                    for (int i = 0; i < list.Count; i++)
                    {
                        var item = list[i];

                        UpdateChartOfAccount(item);
                    }
                }
            }
            catch (Exception ex) { throw new Exception(GetMyMethodName(), ex); }
        }
Exemplo n.º 2
0
        private async Task <ChartOfAccountView> MapToView(ChartOfAccount inputObject)
        {
            Mapper             mapper    = new Mapper();
            ChartOfAccountView outObject = mapper.Map <ChartOfAccountView>(inputObject);
            await Task.Yield();

            return(outObject);
        }