// GET: InquireBlock public ActionResult Index(int projectId) { SampleListViewModel slvm = new SampleListViewModel() { rollersampleinfos = samplerepo.RollerSampleInfos.Where(x => x.RollerProjectInfoID == projectId) }; return(View(slvm)); }
public ActionResult ViewAllInfo(int sampleId) { RollerSampleInfo rollersampleinfo = samplerepo.RollerSampleInfos.FirstOrDefault(x => x.RollerSampleInfoID == sampleId); SampleListViewModel slvm = new SampleListViewModel() { rollersampleinfos = samplerepo.RollerSampleInfos.Where(x => x.RollerProjectInfoID == rollersampleinfo.RollerProjectInfoID) }; ViewAllInfoModel vaim = new ViewAllInfoModel() { samplelistviewmodel = slvm, rollerrecordinfos = recordrepo.RollerRecordInfos.Where(x => x.RollerSampleInfoID == sampleId), rollertestreportinfos = testreportrepo.RollerTestreportInfos.Where(x => x.RollerSampleInfoID == sampleId), rollersampleinfo = rollersampleinfo }; return(View(vaim)); }
public async Task <SampleListViewModel> List(SampleSearchViewModel search) { var filter = Builders <SampleModel> .Filter.Where(q => q.Status == Status.Active); if (search.Id.HasValue) { filter &= Builders <SampleModel> .Filter.Where(q => q.Id == search.Id.Value); } if (!string.IsNullOrEmpty(search.Title)) { filter &= Builders <SampleModel> .Filter.Where(q => q.Title.Contains(search.Title)); } if (search.CreateFrom.HasValue) { var createFromDateTime = search.CreateFrom.ToDateTimeFromUnix(); filter &= Builders <SampleModel> .Filter.Where(q => q.CreateDate >= createFromDateTime); } if (search.CreateTo.HasValue) { var createToDateTime = search.CreateFrom.ToDateTimeFromUnix(); filter &= Builders <SampleModel> .Filter.Where(q => q.CreateDate <= createToDateTime); } var sort = search.OrderBy switch { "Id" => search.Order == SortOrder.Descending ? Builders <SampleModel> .Sort.Descending(q => q.Id) : Builders <SampleModel> .Sort.Ascending(q => q.Id), "CreateDate" => search.Order == SortOrder.Descending ? Builders <SampleModel> .Sort.Descending(q => q.CreateDate) : Builders <SampleModel> .Sort.Ascending(q => q.CreateDate), _ => Builders <SampleModel> .Sort.Descending(x => x.Id) }; var offset = (search.PageNumber - 1) * search.PageSize; var list = await _mongoDbContext.Sample .Find(filter) .Sort(sort) .Skip(offset) .Limit(search.PageSize) .ToListAsync(); search.Total = await _mongoDbContext.Sample.Find(filter).CountDocumentsAsync(); search.TotalPage = (int)Math.Ceiling((decimal)search.Total / search.PageSize); var viewModel = new SampleListViewModel { Search = search, List = list.Select(q => new SampleViewModel { Id = q.Id, Title = q.Title }).ToList() }; viewModel.Search.Total = search.Total; viewModel.Search.TotalPage = search.TotalPage; viewModel.Search.PageNumber = search.PageNumber; viewModel.Search.PageSize = search.PageSize; return(viewModel); }
public List() { InitializeComponent(); BindingContext = new SampleListViewModel(); }