public ActionResult SortingPanel()
        {
            var currentSort = CookieHelper.SortType;

            var sortings = new List <SortItem>
            {
                new SortItem(SortType.Name, L("SortHeaderName"),
                             L("SortTitleName"), SortType.Name == currentSort),

                new SortItem(SortType.Author, L("SortHeaderAuthor"),
                             L("SortTitleAuthor"), SortType.Author == currentSort),

                new SortItem(SortType.Date, L("SortHeaderDate"),
                             L("SortTitleDate"), SortType.Date == currentSort),

                new SortItem(SortType.View, L("SortHeaderView"),
                             L("SortTitleView"), SortType.View == currentSort),

                new SortItem(SortType.Favorite, L("SortHeaderFavorite"),
                             L("SortTitleFavorite"), SortType.Favorite == currentSort),
            };

            var model = new SortingViewModel
            {
                Sortings     = sortings,
                IsDescending = CookieHelper.OrderIsDescending
            };

            return(PartialView("~/Views/Shared/Content/_SortingPanel.cshtml", model));
        }
Beispiel #2
0
        public PlantMessagesViewModel GetPlantMessages(ContextModel context)
        {
            var result = new PlantMessagesViewModel();

            result.messages = GetVueModel(context.ActualPlant, context.AllMachines, context.ActualPeriod);
            if (context.ActualPlant != null)
            {
                result.plant = new PlantInfoViewModel()
                {
                    id   = context.ActualPlant.Id,
                    name = context.ActualPlant.Name
                };


                var sorting = new SortingViewModel
                {
                    timestamp = enSorting.Descending.GetDescription()
                };

                result.sorting = sorting;

                result.UtcOffset = context.AllMachines
                                   .FirstOrDefault(
                    w => w.Id == (result.messages?.FirstOrDefault()?.machine.id ?? 0))?.UTC ?? 0;
            }
            if (context.User.TimeZone != null)
            {
                result.timeZone = context.User.TimeZone;
            }

            return(result);
        }
Beispiel #3
0
        public override async Task <SortingQueryResult> HandleAsync(SortingQuery query)
        {
            var contest = await ReadRepository.Set <Contest>()
                          .Include(x => x.ContestAreas)
                          //.Include($"{nameof(Contest.ContestAreas)}.{nameof(ContestArea.Area)}")
                          //.Include($"{nameof(Contest.ContestRegistrations)}.{nameof(ContestRegistration.Participant1)}")
                          //.Include($"{nameof(Contest.ContestRegistrations)}.{nameof(ContestRegistration.StudyPlace)}")
                          .SingleOrDefaultAsync(m => m.Id == query.ContestId);

            if (contest == null)
            {
                throw new EntityNotFoundException();
            }

            var compClassIds = contest.ContestAreas
                               .Where(ca => !string.IsNullOrEmpty(ca.SortingCompClassIds))
                               .SelectMany(c => c.SortingCompClassIds.Split(',', StringSplitOptions.RemoveEmptyEntries))
                               .Select(int.Parse)
                               .ToArray();

            var viewModel = new SortingViewModel();

            _mapper.Map(contest, viewModel);

            var res = new SortingQueryResult
            {
                ViewModel    = viewModel,
                CompClassIds = compClassIds,
            };

            return(res);
        }
        public static SortingViewModel MapToSortingViewModel(SortingGridMetadata source)
        {
            var target = new SortingViewModel();

            Map(source, target);
            return(target);
        }
Beispiel #5
0
        private MaintenceVueModel GetIgnoredVueModel(List <MessageMachineModel> data, MachineInfoModel machine)
        {
            var result   = new MaintenceVueModel();
            var messages = data.Select(a =>
                                       new ManteinanceDataModel
            {
                id          = a.Id,
                code        = a.Code,
                type        = ((enTypeAlarm)a.Type).GetDescription(),
                time        = CommonViewService.getTimeViewModel(a.ElapsedTime),
                timestamp   = DateTime.SpecifyKind(a.IgnoreDate ?? DateTime.MinValue, DateTimeKind.Utc),
                utc         = machine.UTC,
                expiredSpan = CommonViewService.getTimeViewModel(_messageService.GetExpiredSpan(a)),
                description = a.Description,
                user        = _userManagerViewService.GetUser(a.UserId)
            }).ToList();

            result.messages = messages.OrderByDescending(o => o.time.elapsed).ToList();
            var sorting = new SortingViewModel();

            sorting.duration  = enSorting.Descending.GetDescription();
            sorting.user      = enSorting.Descending.GetDescription();
            sorting.timestamp = enSorting.Descending.GetDescription();

            result.sorting = sorting;
            return(result);
        }
Beispiel #6
0
        private MessageVueModel GetVueModel(MachineInfoModel machine, PeriodModel period, string actualMachineGroup = null)
        {
            var result = new MessageVueModel();

            var data = _messageService.GetAggregationMessages(machine, period, enDataType.Summary, actualMachineGroup);

            if (data.Count == 0)
            {
                return(result);
            }

            var messages = data.Select(a => new MessageDataModel()
            {
                code        = a.Code,
                type        = a.Type != null ? ((enTypeAlarm)a.Type).GetDescription() : "",
                parameters  = a.Params,
                quantity    = a.Count ?? 0,
                day         = a.Day == null ? "-" : a.Day.Value.ToString("t"),
                description = a.Description
            }).ToList();

            messages = messages.OrderByDescending(o => o.quantity).ToList();

            var sorting = new SortingViewModel
            {
                duration = enSorting.Descending.GetDescription()
            };

            result.messages = messages;
            result.sorting  = sorting;

            return(result);
        }
Beispiel #7
0
        public ActionResult Gonderiler(SortingViewModel sorting)
        {
            if (string.IsNullOrEmpty(sorting.Radio) || string.IsNullOrEmpty(sorting.sort))
            {
                return(View(db.articles.ToList()));
            }
            else
            {
                string sort  = sorting.sort;
                string radio = sorting.Radio;

                if (sort == "Tarih")
                {
                    if (radio == "Artan")
                    {
                        return(View(db.articles.OrderBy(r => r.PostedDate)));
                    }
                    else
                    {
                        return(View(db.articles.OrderByDescending(r => r.PostedDate)));
                    }
                }
                else
                {
                    if (radio == "Artan")
                    {
                        return(View(db.articles.OrderBy(r => r.author.NickName)));
                    }
                    else
                    {
                        return(View(db.articles.OrderByDescending(r => r.author.NickName)));
                    }
                }
            }
        }
Beispiel #8
0
        public ActionResult GridSorting(SortingViewModel model, string submitType)
        {
            //if (model.DummyID.HasValue)
            //    model.Content = new ContentViewModel().AddTitle(dummyID.Value.ToString()).AddText("you clicked " + dummyID.Value.ToString());

            if (ModelState.IsValid)
            {
                if ("Search".Equals(submitType, StringComparison.OrdinalIgnoreCase))
                {
                    // Get PageMetadata from view model.
                    SortingGridMetadata metadata = ExampleMapper.MapToSortingGridMetadata(model);//   MappingEngine.Map<SortingGridMetadata>(model);

                    // Use this page metadata to retrieve data via service.
                    IEnumerable <SortModel> results = DummyService.GetAllForSorting(metadata.Name);

                    // Map these results for paging.
                    // Populate Grid property with data and pageMetata.
                    // NOTE: Mapping contains both Source and Destination types. New Pageable instance is created with page Metadata for use with the destination object, to keep pageMetadata.
                    model.Results = results.ToGridSortingViewModelList(new Pageable <GridSortingViewModel>(metadata));// MappingEngine.Map<IEnumerable<SortModel>, IPageable<GridSortingViewModel>>(results, new Pageable<GridSortingViewModel>(metadata));
                }
                else
                {
                    var selectedValues = model.Results.FirstOrDefault(x => x.SortingID == model.SelectedKeys);
                    if (selectedValues != null)
                    {
                        model.SelectedContent = new ContentViewModel().AddTitle("Selected").AddParagraph(selectedValues.Address);
                    }
                }
            }
            return(View(model));
        }
Beispiel #9
0
        public ActionResult GridSorting()
        {
            PageTitle = "Sorts the Grid.";

            var model = new SortingViewModel();

            return(View(model));
        }
Beispiel #10
0
        public void CheckIfUserCanRunProcessingWithoutAnyDirectories()
        {
            var directorySelectorMock = new Mock <IDirectorySelector>();

            var ViewModel            = new SortingViewModel(subDirectoriesSearchMock.Object, imageSortingMock.Object, directorySelectorMock.Object, dialogHostSpy);
            var canExecuteProcessing = ViewModel.RunProcessing.CanExecute(null);

            Assert.IsFalse(canExecuteProcessing);
        }
        public IActionResult GetSorting()
        {
            var sortingViewModel = new SortingViewModel()
            {
                dataSoring        = GetDataSoring(),
                combSortArray     = GetHeapSort(RandomArray),
                quickSortingArray = GetQuickSorting(RandomArray)
            };

            return(Ok(sortingViewModel));
        }
Beispiel #12
0
 public MainWindow()
 {
     SortingViewModel = new SortingViewModel(
         new SubDirectoriesSearch(),
         new ImageSorter(
             new DateTimeClassification(
                 new MetadataCreationDateReader()),
             new MD5Check()),
         new UIDirectoryBrowser(),
         new ProgressControlHost());
     InitializeComponent();
 }
Beispiel #13
0
        public void CheckIfUserCanRunProcessingWithDirectories()
        {
            directorySelectorMock.SetupSequence(d => d.SelectDirectory())
            .Returns(TestPath1)
            .Returns(TestOutputPath);

            var ViewModel = new SortingViewModel(subDirectoriesSearchMock.Object, imageSortingMock.Object, directorySelectorMock.Object, dialogHostSpy);

            ViewModel.AddDirectory.Execute(null);
            ViewModel.SelectOutputDirectory.Execute(null);
            var canExecuteProcessing = ViewModel.RunProcessing.CanExecute(null);

            Assert.IsTrue(canExecuteProcessing);
        }
Beispiel #14
0
        public IHttpActionResult GetSorted([FromUri] string filterJson, int lowerBound, int upperBound, string sortHeader, string sortDirection)
        {
            var filter = JsonConvert.DeserializeObject <FilterViewModel>(filterJson, new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Include
            });

            var sorting = new SortingViewModel
            {
                SortHeader    = (SortHeader)System.Enum.Parse(typeof(SortHeader), sortHeader),
                SortDirection = (SortDirection)System.Enum.Parse(typeof(SortDirection), sortDirection)
            };

            return(Ok(_serviceWorker.GetSortedAcousticClassicalGuitars(filter, lowerBound, upperBound, sorting)));
        }
        private ToolVueModel GetVueModel(MachineInfoModel machine, bool xmodule = false)
        {
            ToolVueModel result = new ToolVueModel();

            List <ToolMachineModel> data = _toolService.GetTools(machine, xmodule);

            List <ToolMachineModel> dataTools = data.Where(w => w.IsActive).ToList();

            //List<ToolMachineModel> dataHistorical = data.Where(w => w.IsActive == false).ToList();

            if (dataTools.Count == 0)
            {
                return(result);
            }
            var lan = _contextService.GetContext().ActualLanguage.InitialsLanguage;
            List <ToolDataModel> tools = dataTools.Select(t => new ToolDataModel()
            {
                code        = t.Code,
                description = t.Description,
                perc        = Common.GetPercentage(t.CurrentLife, t.ExpectedLife),
                changes     = new ChangeModel()
                {
                    //total = (t.BrokenEventsCount ?? 0) + (t.RevisedEventsCount ?? 0),
                    breaking    = 0,
                    replacement = 0,
                    //historical = dataHistorical.Where(w => w.Code == t.Code).Select(h => new HistoricalModel()
                    //{
                    //    date = h.DateReplaced.ToString(),
                    //    type = CommonViewService.GetTypeTool(h).ToLocalizedString(lan),
                    //    color_type = CommonViewService.GetTypeTool(h).GetDescription(),
                    //    duration = CommonViewService.getTimeViewModel(h.CurrentLife)
                    //}).OrderByDescending(o => o.date).ToList()
                },
                time = CommonViewService.getTimeViewModel((t.ExpectedLife ?? 0) - (t.CurrentLife ?? 0))
            }).ToList();

            tools = tools.OrderByDescending(o => o.perc).ToList();

            SortingViewModel sorting = new SortingViewModel();

            sorting.time = enSorting.Descending.GetDescription();

            result.tools   = tools;
            result.sorting = sorting;

            return(result);
        }
Beispiel #16
0
        public void CheckIfUserCanAddTheSameDirectory()
        {
            directorySelectorMock.SetupSequence(d => d.SelectDirectory())
            .Returns(TestPath1)
            .Returns(TestPath1)
            .Returns(TestPath1);

            var ViewModel = new SortingViewModel(subDirectoriesSearchMock.Object, imageSortingMock.Object, directorySelectorMock.Object, dialogHostSpy);

            ViewModel.AddDirectory.Execute(null);
            ViewModel.AddDirectory.Execute(null);
            ViewModel.AddDirectory.Execute(null);



            Assert.AreEqual(1, ViewModel.InputDirectories.Count);
            Assert.AreEqual(TestPath1, ViewModel.InputDirectories[0]);
        }
Beispiel #17
0
        public void TestAddDirectoryMethod()
        {
            directorySelectorMock.SetupSequence(d => d.SelectDirectory())
            .Returns(TestPath1)
            .Returns(TestPath2)
            .Returns(TestPath3);

            var ViewModel = new SortingViewModel(subDirectoriesSearchMock.Object, imageSortingMock.Object, directorySelectorMock.Object, dialogHostSpy);

            ViewModel.AddDirectory.Execute(null);
            ViewModel.AddDirectory.Execute(null);
            ViewModel.AddDirectory.Execute(null);

            Assert.AreEqual(3, ViewModel.InputDirectories.Count);
            Assert.AreEqual(TestPath1, ViewModel.InputDirectories[0]);
            Assert.AreEqual(TestPath2, ViewModel.InputDirectories[1]);
            Assert.AreEqual(TestPath3, ViewModel.InputDirectories[2]);
        }
Beispiel #18
0
        private JobVueModel GetVueModel(MachineInfoModel machine, PeriodModel period)
        {
            var result = new JobVueModel();

            var data = _jobService.GetAggregationJobs(machine, period);

            if (data.Count == 0)
            {
                return(result);
            }

            CurrentStateModel currentState = null;

            if (machine.Model.Name.ToUpper().Contains("FMC") ||
                (machine.Model.Name.ToUpper().Contains("LMX")))
            {
                currentState = GetCurrentState(machine.Id);
            }

            var jobs = data.Select(j => new JobDataModel()
            {
                code     = j.Code,
                perc     = getPercent(j),
                time     = CommonViewService.getTimeViewModel(j.ElapsedTime),
                quantity = j.PiecesProduced ?? 0,
                pieces   = j.TotalPieces != null && (j.TotalPieces > 0 && !j.Code.ToUpper().StartsWith("M#2")) ? (int)j.TotalPieces : (int)j.PiecesProduced,
                day      = j.Day.GetValueOrDefault(),
                ResidueWorkingTimeJob = getResTime(currentState, j)
            }).ToList();

            jobs = jobs.OrderBy(o => o.perc).ToList();

            var sorting = new SortingViewModel
            {
                progress = enSorting.Ascending.GetDescription()
            };

            result.jobs    = jobs;
            result.sorting = sorting;


            return(result);
        }
Beispiel #19
0
        private MessageDetailsVueModel GetMessageDetails(MachineInfoModel actualMachine, PeriodModel actualPeriod, string actualMachineGroup = null)
        {
            var result = new MessageDetailsVueModel();

            var data = _messageService.GetMessageDetails(actualMachine, actualPeriod, actualMachineGroup);

            if (data.Count == 0)
            {
                return(result);
            }

            var messages = data.Select(a => new MessageDetailViewModel()
            {
                code        = a.Code,
                parameters  = a.Params,
                timestamp   = DateTime.SpecifyKind(a.Day ?? DateTime.MinValue, DateTimeKind.Utc),
                utc         = actualMachine.UTC ?? 0,
                type        = ((enTypeAlarm)a.Type).GetDescription(),
                group       = a.GroupName,
                time        = CommonViewService.getTimeViewModel(a.ElapsedTime),
                description = a.Description
            }).ToList();

            messages = messages.OrderByDescending(o => o.timestamp).ToList();

            var sorting = new SortingViewModel();

            sorting.timestamp = enSorting.Descending.GetDescription();

            sorting.group = enSorting.Ascending.GetDescription();
            sorting.user  = enSorting.Ascending.GetDescription();

            result.messages = messages;
            result.sorting  = sorting;



            return(result);
        }
Beispiel #20
0
        public void CheckFileCopyModeProcessingSelection()
        {
            int calls = 0;

            imageSortingMock.Setup(
                i => i.Sort(
                    It.Is <IEnumerable <string> >(input => input.Count() > 0),
                    It.Is <string>(output => !string.IsNullOrEmpty(output)),
                    It.Is <IFileOperation>(operation => operation is FileCopyOperation)))
            .Callback(() => calls++);

            directorySelectorMock.SetupSequence(d => d.SelectDirectory())
            .Returns(TestPath1);


            var ViewModel = new SortingViewModel(subDirectoriesSearchMock.Object, imageSortingMock.Object, directorySelectorMock.Object, dialogHostSpy);

            ViewModel.OutputDirectory = TestOutputPath;
            ViewModel.FileMode        = PhotoKinia.Models.FileOperationMode.Copy;
            ViewModel.AddDirectory.Execute(null);
            ViewModel.RunProcessing.Execute(null);
            Assert.AreEqual(1, calls);
        }
Beispiel #21
0
        public async Task CheckIfSortingWasCalledAfterClickingRunProcessingButton()
        {
            int calls = 0;

            imageSortingMock.Setup(
                i => i.Sort(
                    It.Is <IEnumerable <string> >(input => input.Count() > 0),
                    It.Is <string>(output => !string.IsNullOrEmpty(output)),
                    It.Is <IFileOperation>(operation => operation != null)))
            .Callback(() => calls++);

            directorySelectorMock.SetupSequence(d => d.SelectDirectory())
            .Returns(TestPath1);

            var ViewModel = new SortingViewModel(subDirectoriesSearchMock.Object, imageSortingMock.Object, directorySelectorMock.Object, dialogHostSpy);

            ViewModel.OutputDirectory = TestOutputPath;
            ViewModel.AddDirectory.Execute(null);
            await ViewModel.RunProcessing.ExecuteAsync(null);

            Assert.AreEqual(1, dialogHostSpy.NumberOfCalls);
            Assert.IsInstanceOfType(dialogHostSpy.PassedObject, typeof(ProgressControlViewModel));
        }
Beispiel #22
0
        private MaintenceVueModel GetKpiVueModel(List <MessageMachineModel> data, MachineInfoModel machine)
        {
            var result   = new MaintenceVueModel();
            var messages = data.Select(a =>
                                       new ManteinanceDataModel
            {
                id          = a.Id,
                day         = (DateTime)a.Day?.Date,
                ignoreDate  = (DateTime)a.IgnoreDate?.Date,
                dateDiff    = ((TimeSpan)(a.IgnoreDate?.Date - a.Day?.Date)).TotalDays,
                utc         = machine.UTC,
                description = a.Description,
                user        = _userManagerViewService.GetUser(a.UserId)
            }).ToList();

            result.messages = messages.OrderByDescending(o => o.day).ToList();
            var sorting = new SortingViewModel();

            sorting.user     = enSorting.Descending.GetDescription();
            sorting.dateDiff = enSorting.Descending.GetDescription();
            result.sorting   = sorting;
            return(result);
        }
        public async Task <IActionResult> Sorting(int id, SortingViewModel viewModel)
        {
            try
            {
                await HandlerDispatcher.ExecuteCommandAsync(new SortingCommand { ContestId = id, ViewModel = viewModel });
            }
            catch (ValidationException e)
            {
                e.ValidationResult.ForEach(res => ModelState.AddModelError(res.Key, res.Value));

                var data1 = await HandlerDispatcher.ExecuteQueryAsync(new GetDataForSortingQuery { ContestId = id, SelectedContestAreaId = viewModel.SelectedContestAreaId, SelectedCompClassIds = viewModel.SelectedCompClassIds });

                FillSortingViewData(data1.ContestAreas, data1.CompClasses);

                return(View(viewModel));
            }

            var data = await HandlerDispatcher.ExecuteQueryAsync(new GetDataForSortingQuery { ContestId = id, SelectedContestAreaId = viewModel.SelectedContestAreaId, SelectedCompClassIds = viewModel.SelectedCompClassIds });

            FillSortingViewData(data.ContestAreas, data.CompClasses);

            return(View(viewModel));
        }
Beispiel #24
0
        private MaintenceVueModel GetVueModel(MachineInfoModel machine, PeriodModel period)
        {
            var result = new MaintenceVueModel();

            var data = _messageService.GetMaintenanceMessages(machine, period);

            if (data.Count == 0)
            {
                return(result);
            }

            var messages = data.Select(a =>
                                       new ManteinanceDataModel()
            {
                id          = a.Id,
                code        = a.Code,
                type        = ((enTypeAlarm)a.Type).GetDescription(),
                time        = CommonViewService.getTimeViewModel(a.ElapsedTime),
                timestamp   = DateTime.SpecifyKind(a.Day ?? DateTime.MinValue, DateTimeKind.Utc),
                utc         = machine.UTC,
                expiredSpan = CommonViewService.getTimeViewModel(_messageService.GetExpiredSpan(a)),
                description = a.Description,
                icon        = GetIcon(a)
            }).ToList();

            messages = messages.OrderByDescending(o => o.time.elapsed).ToList();

            var sorting = new SortingViewModel();

            sorting.duration = enSorting.Descending.GetDescription();

            result.messages = messages;
            result.sorting  = sorting;


            return(result);
        }
Beispiel #25
0
 public List <CustomerContactViewModel> Search(CustomerContactQueryCondition cond, PagingViewModel paging, SortingViewModel sort)
 {
     return(this.GetSearchIQuerable(cond)
            .Sort(sort)
            .Skip(paging.Skip)
            .Take(paging.Take)
            .AsNoTracking()
            .Select(x => new CustomerContactViewModel()
     {
         CompanyNumber = x.客戶資料.統一編號,
         CustomerName = x.客戶資料.客戶名稱,
         Email = x.Email,
         Id = x.Id,
         姓名 = x.姓名,
         手機 = x.手機,
         職稱 = x.職稱,
         電話 = x.電話
     }).ToList());
 }
        public List <客戶資料> Search(CustomerQueryInModel cond, PagingViewModel paging, SortingViewModel sort)
        {
            var query = this.GetSearchIQueryable(cond);

            return(query.Sort(sort).Skip(paging.Skip).Take(paging.Take).AsNoTracking().ToList());
        }
Beispiel #27
0
        public static IQueryable <客戶聯絡人> Sort(this IQueryable <客戶聯絡人> baseQuery, SortingViewModel sort)
        {
            if (!string.IsNullOrEmpty(sort.Sort) && !string.IsNullOrEmpty(sort.Column))
            {
                if (sort.Sort.Equals("asc"))
                {
                    switch (sort.Column)
                    {
                    case ("CompanyNumber"):
                        baseQuery = baseQuery.OrderBy(x => x.客戶資料.統一編號);
                        break;

                    case ("CustomerName"):
                        baseQuery = baseQuery.OrderBy(x => x.客戶資料.客戶名稱);
                        break;

                    case ("ContactName"):
                        baseQuery = baseQuery.OrderBy(x => x.姓名);
                        break;

                    case ("Mobile"):
                        baseQuery = baseQuery.OrderBy(x => x.手機);
                        break;

                    case ("Phone"):
                        baseQuery = baseQuery.OrderBy(x => x.電話);
                        break;

                    case ("JobName"):
                        baseQuery = baseQuery.OrderBy(x => x.職稱);
                        break;

                    case ("Email"):
                        baseQuery = baseQuery.OrderBy(x => x.Email);
                        break;

                    case ("Id"):
                        baseQuery = baseQuery.OrderBy(x => x.Id);
                        break;

                    default:
                        break;
                    }
                }
                else if (sort.Sort.Equals("desc"))
                {
                    switch (sort.Column)
                    {
                    case ("CompanyNumber"):
                        baseQuery = baseQuery.OrderByDescending(x => x.客戶資料.統一編號);
                        break;

                    case ("CustomerName"):
                        baseQuery = baseQuery.OrderByDescending(x => x.客戶資料.客戶名稱);
                        break;

                    case ("ContactName"):
                        baseQuery = baseQuery.OrderByDescending(x => x.姓名);
                        break;

                    case ("Mobile"):
                        baseQuery = baseQuery.OrderByDescending(x => x.手機);
                        break;

                    case ("Phone"):
                        baseQuery = baseQuery.OrderByDescending(x => x.電話);
                        break;

                    case ("JobName"):
                        baseQuery = baseQuery.OrderByDescending(x => x.職稱);
                        break;

                    case ("Email"):
                        baseQuery = baseQuery.OrderByDescending(x => x.Email);
                        break;

                    case ("Id"):
                        baseQuery = baseQuery.OrderByDescending(x => x.Id);
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                baseQuery = baseQuery.OrderByDescending(x => x.Id);
            }
            return(baseQuery);
        }
        public static IQueryable <客戶資料> Sort(this IQueryable <客戶資料> baseQuery, SortingViewModel sort)
        {
            if (!string.IsNullOrEmpty(sort.Sort) && !string.IsNullOrEmpty(sort.Column))
            {
                if (sort.Sort.Equals("asc"))
                {
                    switch (sort.Column)
                    {
                    case ("ClientName"):
                        baseQuery = baseQuery.OrderBy(x => x.客戶名稱);
                        break;

                    case ("CompanyNumber"):
                        baseQuery = baseQuery.OrderBy(x => x.統一編號);
                        break;

                    case ("CustomerTypeName"):
                        baseQuery = baseQuery.OrderBy(x => x.客戶類別.類別名稱);
                        break;

                    case ("Phone"):
                        baseQuery = baseQuery.OrderBy(x => x.電話);
                        break;

                    case ("Fax"):
                        baseQuery = baseQuery.OrderBy(x => x.傳真);
                        break;

                    case ("Address"):
                        baseQuery = baseQuery.OrderBy(x => x.地址);
                        break;

                    case ("Email"):
                        baseQuery = baseQuery.OrderBy(x => x.Email);
                        break;

                    case ("Id"):
                        baseQuery = baseQuery.OrderBy(x => x.Id);
                        break;

                    default:
                        break;
                    }
                }
                else if (sort.Sort.Equals("desc"))
                {
                    switch (sort.Column)
                    {
                    case ("ClientName"):
                        baseQuery = baseQuery.OrderByDescending(x => x.客戶名稱);
                        break;

                    case ("CompanyNumber"):
                        baseQuery = baseQuery.OrderByDescending(x => x.統一編號);
                        break;

                    case ("CustomerTypeName"):
                        baseQuery = baseQuery.OrderByDescending(x => x.客戶類別.類別名稱);
                        break;

                    case ("Phone"):
                        baseQuery = baseQuery.OrderByDescending(x => x.電話);
                        break;

                    case ("Fax"):
                        baseQuery = baseQuery.OrderByDescending(x => x.傳真);
                        break;

                    case ("Address"):
                        baseQuery = baseQuery.OrderByDescending(x => x.地址);
                        break;

                    case ("Email"):
                        baseQuery = baseQuery.OrderByDescending(x => x.Email);
                        break;

                    case ("Id"):
                        baseQuery = baseQuery.OrderByDescending(x => x.Id);
                        break;

                    default:
                        break;
                    }
                }
            }
            else
            {
                baseQuery = baseQuery.OrderByDescending(x => x.Id);
            }
            return(baseQuery);
        }
 public static void Map(SortingViewModel source, SortingGridMetadata target)
 {
     target.Name = source.Name;
 }
Beispiel #30
0
 public GuitarList GetSortedAcousticWesternGuitars(FilterViewModel filter, int lowerBound, int upperBound, SortingViewModel sorting)
 {
     return(new GuitarList
     {
         Guitars = ServiceMappings.Map <List <AcousticWesternGuitarViewModel> >
                   (
             _unitOfWork.WesternAcousticGuitars.GetSorted(ServiceMappings.Map <FilterDataModel>(filter),
                                                          lowerBound,
                                                          upperBound,
                                                          ServiceMappings.Map <SortingDataModel>(sorting))
                   )
     });
 }