public async Task <ApiResponse> GetStockHistory(Pagination request = null)
        {
            try
            {
                request = request ?? new Pagination
                {
                    page        = request.page,
                    rowsPerPage = request.rowsPerPage
                };

                var stocks = dbContext.stocks
                             .Where(r => !r.deleted)
                             .OrderBy(r => r.lastUpdate);

                var count = await stocks.CountAsync();

                var pagination = new PaginationResponse
                {
                    page        = request.page,
                    pageCount   = (int)Math.Ceiling(count * 1.0 / request.rowsPerPage),
                    rowCount    = count,
                    rowsPerPage = request.rowsPerPage
                };
                var response = await stocks
                               .Skip(request.rowsPerPage *(request.page - 1))
                               .Take(request.rowsPerPage)
                               .ToListAsync();

                return(pagination.CreateResponse(response));
            }
            catch (Exception e)
            {
                return((e.InnerException).Message.CreateResponse());
            }
        }
        public async Task <ApiResponse> GetCompanyList(Pagination request = null)
        {
            try
            {
                request = request ?? new Pagination
                {
                    page        = request.page,
                    rowsPerPage = request.rowsPerPage
                };

                var company = dbContext.companies
                              .Where(r => !r.deleted);

                var count = await company.CountAsync();

                var pagination = new PaginationResponse
                {
                    page        = request.page,
                    pageCount   = (int)Math.Ceiling(count * 1.0 / request.rowsPerPage),
                    rowCount    = count,
                    rowsPerPage = request.rowsPerPage
                };
                var response = await company
                               .Skip(request.rowsPerPage *(request.page - 1))
                               .Take(request.rowsPerPage)
                               .ToListAsync();

                return(pagination.CreateResponse(response));
            }
            catch (Exception e)
            {
                return((e.InnerException).Message.CreateResponse());
            }
        }
        public async Task <ApiResponse> GetCategoryList(Pagination request = null)
        {
            try
            {
                request = request ?? new Pagination
                {
                    page        = request.page,
                    rowsPerPage = request.rowsPerPage
                };

                var subCategories = dbContext.categories
                                    .Join(dbContext.categories, c => c.id, sc => sc.parentId, (c, sc) => new { c, sc })
                                    .Join(dbContext.users, y => y.sc.editedBy, x => x.objectSid, (y, x) => new { y, x })
                                    .Where(r => !r.x.deleted && !r.y.sc.deleted && !r.y.c.deleted)
                                    .OrderBy(r => r.y.c.name)
                                    .Select(r => new
                {
                    parentName = r.y.c.name,
                    parentId   = r.y.c.id,
                    childName  = r.y.sc.name,
                    childId    = r.y.sc.id,
                    editedBy   = r.x.displayName,
                    lastUpdate = r.y.sc.lastUpdate
                });

                var count = await subCategories.CountAsync();

                var pagination = new PaginationResponse
                {
                    page        = request.page,
                    pageCount   = (int)Math.Ceiling(count * 1.0 / request.rowsPerPage),
                    rowCount    = count,
                    rowsPerPage = request.rowsPerPage
                };
                var response = await subCategories
                               .Skip(request.rowsPerPage *(request.page - 1))
                               .Take(request.rowsPerPage)
                               .ToListAsync();

                return(pagination.CreateResponse(response));
            }
            catch (Exception e)
            {
                return((e.InnerException ?? e).Message.CreateResponse());
            }
        }