public async Task <int> CreateAsync(AccountingBookModel model)
        {
            try
            {
                var existResultCode = await FindbyCode(model.Code);

                if (existResultCode != null)
                {
                    throw new Exception("Code Already Exist");
                }

                var existResultName = await FindByName(model.AccountingBookType);

                if (existResultName != null)
                {
                    throw new Exception("Name Already Exist");
                }


                EntityExtension.FlagForCreate(model, _identityService.Username, UserAgent);
                _dbContext.AccountingBooks.Add(model);

                await _dbContext.SaveChangesAsync();

                return(model.Id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public Task <int> UpdateAsync(int id, AccountingBookModel model)
        {
            try
            {
                var models = _dbContext.AccountingBooks.Where(entity => entity.Id.Equals(id)).FirstOrDefault();

                var existResultCode = FindbyCodeUpdate(model.Code, id);
                if (existResultCode > 0)
                {
                    throw new Exception("Code: Code Already Exist");
                }

                var existResultName = FindbyNameUpdate(model.AccountingBookType, id);
                if (existResultName > 0)
                {
                    throw new Exception("AccountBookType: Name Already Exist");
                }


                models.AccountingBookType = model.AccountingBookType;
                models.Code    = model.Code;
                models.Remarks = model.Remarks;

                EntityExtension.FlagForUpdate(models, _identityService.Username, UserAgent);
                _dbContext.AccountingBooks.Update(models);

                return(_dbContext.SaveChangesAsync());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }