コード例 #1
0
        public async Task <string> GetAll(DatatableParametersDto dataItems)
        {
            string output = "";
            string error  = "";
            DataTableData <PatientProfileDto> dataTableData = new DataTableData <PatientProfileDto>();

            try
            {
                var query = _dbContext.PatientProfiles.Select(x => new PatientProfileDto
                {
                    Requisitions = _mapper.Map <ICollection <Requisition>, ICollection <RequisitionDto> >(x.Requisitions),//MapAddress(x.Address),
                    PatientId    = x.PatientId,
                    Patient      = _mapper.Map <PatientDto>(x.Patient),
                    Id           = x.Id
                });

                var    totalCount    = query.Count();
                int    sortColumn    = -1;
                string sortDirection = "asc";

                if (dataItems.Length <= 0)
                {
                    dataItems.Length = totalCount;
                }
                if (dataItems.Draw <= 0)
                {
                    dataItems.Draw = 10;
                }
                if (dataItems.Start <= -1)
                {
                    dataItems.Start = 0;
                }

                dataTableData.draw         = dataItems.Draw;
                dataTableData.recordsTotal = totalCount;
                // Paging
                if (dataItems.Length != totalCount)
                {
                    query = query.Skip(dataItems.Start).Take(dataItems.Length);
                }
                //Search
                // Apply filters

                /*if (!string.IsNullOrEmpty(dataItems.Search) || !string.IsNullOrWhiteSpace(dataItems.Search))
                 * {
                 *  var value = dataItems.Search.Trim();
                 *  query = query.Where(p => p..ToString().Contains(value));
                 * }*/
                var data = await query.ToListAsync();

                dataTableData.recordsFiltered = totalCount;
                dataTableData.data            = data;
                output = JsonConvert.SerializeObject(dataTableData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(output);
        }
コード例 #2
0
        public async Task <string> GetAll(DatatableParametersDto dataItems)
        {
            string output = "";
            string error  = "";
            DataTableData <NormalRangeDto> dataTableData = new DataTableData <NormalRangeDto>();

            try
            {
                var query = (from range in _dbContext.NormalRanges
                             select new NormalRangeDto
                {
                    Description = range.Description,
                    Id = range.Id
                });

                var    totalCount    = query.Count();
                int    sortColumn    = -1;
                string sortDirection = "asc";

                if (dataItems.Length <= 0)
                {
                    dataItems.Length = totalCount;
                }
                if (dataItems.Draw <= 0)
                {
                    dataItems.Draw = 10;
                }
                if (dataItems.Start <= -1)
                {
                    dataItems.Start = 0;
                }

                dataTableData.draw         = dataItems.Draw;
                dataTableData.recordsTotal = totalCount;
                // Paging
                if (dataItems.Length != totalCount)
                {
                    query = query.Skip(dataItems.Start).Take(dataItems.Length);
                }
                //Search
                // Apply filters
                if (totalCount > 0 && (!string.IsNullOrEmpty(dataItems.Search) || !string.IsNullOrWhiteSpace(dataItems.Search)))
                {
                    var value = dataItems.Search.Trim();
                    query = query.Where(p => p.Description.Contains(value));
                }
                var data = await query.ToListAsync();

                dataTableData.recordsFiltered = totalCount;
                dataTableData.data            = data;
                output = JsonConvert.SerializeObject(dataTableData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(output);
        }
コード例 #3
0
ファイル: TestService.cs プロジェクト: selebogos/LancetApp
        public async Task <string> GetAll(DatatableParametersDto dataItems)
        {
            string output = "";
            string error  = "";
            DataTableData <TestDto> dataTableData = new DataTableData <TestDto>();

            try
            {
                var query = _dbContext.Tests.Select(x => new TestDto
                {
                    Name          = x.Name,
                    Comment       = x.Comment,
                    NormalValue   = _mapper.Map <NormalRangeDto>(x.NormalValue),//MapAddress(x.Address),
                    NormalValueId = x.NormalValueId,
                    TestResult    = _mapper.Map <TestResultDto>(x.TestResult),
                    TestResultId  = x.TestResultId,
                    Id            = x.Id
                });

                var    totalCount    = query.Count();
                int    sortColumn    = -1;
                string sortDirection = "asc";

                if (dataItems.Length <= 0)
                {
                    dataItems.Length = totalCount;
                }
                if (dataItems.Draw <= 0)
                {
                    dataItems.Draw = 10;
                }
                if (dataItems.Start <= -1)
                {
                    dataItems.Start = 0;
                }

                dataTableData.draw         = dataItems.Draw;
                dataTableData.recordsTotal = totalCount;
                // Paging
                if (dataItems.Length != totalCount)
                {
                    query = query.Skip(dataItems.Start).Take(dataItems.Length);
                }
                //Search
                // Apply filters
                if (totalCount > 0 && (!string.IsNullOrEmpty(dataItems.Search) || !string.IsNullOrWhiteSpace(dataItems.Search)))
                {
                    var value = dataItems.Search.Trim();
                    query = query.Where(p => p.Name.Contains(value));
                }
                var data = await query.ToListAsync();

                dataTableData.recordsFiltered = totalCount;
                dataTableData.data            = data;
                output = JsonConvert.SerializeObject(dataTableData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(output);
        }
コード例 #4
0
ファイル: PatientService.cs プロジェクト: selebogos/LancetApp
        public async Task <string> GetAll(DatatableParametersDto dataItems)
        {
            string output = "";
            string error  = "";
            DataTableData <PatientDto> dataTableData = new DataTableData <PatientDto>();

            try
            {
                var query = (from patient in _dbContext.Patients
                             join user in _dbContext.Users
                             on patient.AddedById equals user.Id
                             select new PatientDto
                {
                    Address = patient.Address,
                    FullName = patient.FullName,
                    CreatedBy = patient.User.Email,
                    Id = patient.Id
                });

                var    totalCount    = query.Count();
                int    sortColumn    = -1;
                string sortDirection = "asc";

                if (dataItems.Length <= 0)
                {
                    dataItems.Length = totalCount;
                }
                if (dataItems.Draw <= 0)
                {
                    dataItems.Draw = 10;
                }
                if (dataItems.Start <= -1)
                {
                    dataItems.Start = 0;
                }

                dataTableData.draw         = dataItems.Draw;
                dataTableData.recordsTotal = totalCount;
                // Paging
                if (dataItems.Length != totalCount)
                {
                    query = query.Skip(dataItems.Start).Take(dataItems.Length);
                }
                //Search
                // Apply filters
                if (totalCount > 0 && (!string.IsNullOrEmpty(dataItems.Search) || !string.IsNullOrWhiteSpace(dataItems.Search)))
                {
                    var value = dataItems.Search.Trim();
                    query = query.Where(p => p.FullName.Contains(value));
                }
                var data = await query.ToListAsync();

                dataTableData.recordsFiltered = totalCount;
                dataTableData.data            = data;
                output = JsonConvert.SerializeObject(dataTableData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(output);
        }
コード例 #5
0
ファイル: OrderService.cs プロジェクト: selebogos/MyDearship
        public async Task <string> GetAll(DatatableParametersDto dataItems)
        {
            string output = "";
            string error  = "";
            DataTableData <OrderDto> dataTableData = new DataTableData <OrderDto>();

            try
            {
                var query = _dbContext.Orders.Select(x => new OrderDto
                {
                    DateCreated = x.DateCreated,
                    ProfileId   = x.ProfileId,
                    OrderNumber = x.OrderNumber,
                    Id          = x.Id
                });

                var    totalCount    = query.Count();
                int    sortColumn    = -1;
                string sortDirection = "asc";

                if (dataItems.Length <= 0)
                {
                    dataItems.Length = totalCount;
                }
                if (dataItems.Draw <= 0)
                {
                    dataItems.Draw = 10;
                }
                if (dataItems.Start <= -1)
                {
                    dataItems.Start = 0;
                }

                dataTableData.draw         = dataItems.Draw;
                dataTableData.recordsTotal = totalCount;
                // Paging
                if (dataItems.Length != totalCount)
                {
                    query = query.Skip(dataItems.Start).Take(dataItems.Length);
                }
                //Search
                // Apply filters

                /*if (!string.IsNullOrEmpty(dataItems.Search) || !string.IsNullOrWhiteSpace(dataItems.Search))
                 * {
                 *  var value = dataItems.Search.Trim();
                 *  query = query.Where(p => p..ToString().Contains(value));
                 * }*/
                var data = await query.Select(x => new OrderDto {
                    Id = x.Id, DateCreated = x.DateCreated, Amount = x.Amount
                }).ToListAsync();

                dataTableData.recordsFiltered = totalCount;
                dataTableData.data            = data;
                output = JsonConvert.SerializeObject(dataTableData, Formatting.Indented);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            return(output);
        }