public void Search(string text) { Searched = true; Model = new ListModel<RepositoryDetailedModel> { Data = Application.Client.Repositories.Search(text).Repositories }; Render(); }
public async Task<ListModel<EventModel>> GetEvents(string searchTerm = "", bool onlyOpenEvents = true, bool onlySubscriped = false, DateTime? tilDate = null, int pageSize = 25, int page = 0) { var count = await AppRepository.Events.GetCountAsync(this.CurrentUserId, searchTerm, onlyOpenEvents, onlySubscriped, tilDate); var dbentries = await AppRepository.Events.GetEventsAsync(this.CurrentUserId, searchTerm, onlyOpenEvents, onlySubscriped, tilDate, pageSize, page); var result = new ListModel<EventModel>() { AllEntriesCount = count, Entries = dbentries.Select(x => AppModelFactory.CreateViewModel(x, CurrentUserId)).ToList(), Page = page, PageSize = pageSize }; return result; }
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { ListModel model = new ListModel(); foreach (var value in values) { if (value is ListCollectionView) model.List = value as ListCollectionView; else if (value is PlayVideoTrack) model.PlayVideoTrack = value as PlayVideoTrack; else if (value is PlayAudioTrack) model.PlayAudioTrack = value as PlayAudioTrack; else if (value is PlayAlbum) model.PlayAlbum = value as PlayAlbum; } return model; }
public async Task <IActionResult> Index(string term, int page = 1) { var blog = await DataService.CustomFields.GetBlogSettings(); var model = new ListModel { Blog = blog, PostListType = PostListType.Blog }; var pgr = new Pager(page, blog.ItemsPerPage); if (string.IsNullOrEmpty(term)) { if (blog.IncludeFeatured) { model.Posts = await DataService.BlogPosts.GetList(pgr, 0, "", "FP"); } else { model.Posts = await DataService.BlogPosts.GetList(pgr, 0, "", "P"); } } else { model.Posts = await DataService.BlogPosts.Search(pgr, term, 0, "FP"); } if (pgr.ShowOlder) { pgr.LinkToOlder = $"blog?page={pgr.Older}"; } if (pgr.ShowNewer) { pgr.LinkToNewer = $"blog?page={pgr.Newer}"; } model.Pager = pgr; if (!string.IsNullOrEmpty(term)) { model.Blog.Title = term; model.Blog.Description = ""; model.PostListType = PostListType.Search; } return(View($"~/Views/Themes/{blog.Theme}/List.cshtml", model)); }
private void toolStripButton1_Click(object sender, EventArgs e) { this.dataGridView1.CurrentCell = null; var listM = new List <ListModel>(); for (int i = this.dataGridView1.RowCount; i > 0; i--) { ListModel lm = new ListModel(); if (this.dataGridView1.Rows[i - 1].Cells["conversion"].Value != DBNull.Value) { lm.conversion = Math.Round(Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["conversion"].Value), 2); } lm.id = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["id"].Value); if (this.dataGridView1.Rows[i - 1].Cells["quantity"].Value == DBNull.Value || this.dataGridView1.Rows[i - 1].Cells["price"].Value == DBNull.Value) { MessageBox.Show("物料缺失数量,价格!"); return; } lm.quantity = Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["quantity"].Value); lm.price = Convert.ToDouble(this.dataGridView1.Rows[i - 1].Cells["price"].Value); lm.isBatch = Convert.ToBoolean(this.dataGridView1.Rows[i - 1].Cells["isBatch"].Value); if (this.dataGridView1.Rows[i - 1].Cells["combination"].Value != DBNull.Value) { lm.combination = Convert.ToInt32(this.dataGridView1.Rows[i - 1].Cells["combination"].Value); } if (lm.id == 0) { MessageBox.Show("错误,请重新加载窗口!"); return; } listM.Add(lm); } var msg = ctrl.setList(gm, listM); if (msg.Code == 0) { //this.Hide(); MessageBox.Show(msg.Msg); } else { MessageBox.Show(msg.Msg); } }
public void BadBranchId_ReturnsNull() { // arrange IHistoryListLogic testunit = MakeTestsObject(); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "XXX", CustomerId = "123456" }; UserProfile fakeUser = new UserProfile(); // act ListModel results = testunit.GetListModel(fakeUser, testcontext, 0); // assert results.Should() .BeNull(); }
public void CanRemoveMiddleItem() { ListModel <int> list = null; "Given non empty single model list" .x(() => { list = new ListModel <int>(); list.AddInTail(1); list.AddInTail(2); list.AddInTail(3); list.AddInTail(4); list.AddInTail(5); }); "And cursor set in item 4" .x(() => { list.CursorToHead(); list.SetToNextSameItem(4); }); "When user tries to remove current item" .x(() => { list.RemoveItem(); }); "Then system must return head item and set cursor to new head" .x(() => { var items = list.GetItems(); var isSet = list.IsCursorSet(); var item = list.GetItem(); var expected = new List <int>() { 1, 2, 3, 5 }; isSet.Should().BeTrue(); item.Should().Be(5); items.Should().BeEquivalentTo(expected); }); }
public void GoodCustomerIdAndBranch_ReturnsExpectedList() { // arrange INotesListLogic testunit = MakeTestsObject(); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "123456" }; int expectedListId = 1; // act ListModel results = testunit.GetList(testcontext); // assert results.ListId .Should() .Be(expectedListId); }
public void WhenBulletedListInvoked_TheViewModelIsUpdated(string key, string value) { var values = new Dictionary <string, string>() { { key, value } }; var component = new BulletedList(); component.ViewComponentContext = ViewComponentTestHelper.GetViewComponentContext(); ViewViewComponentResult result = component.Invoke(values) as ViewViewComponentResult; ListModel resultModel = (ListModel)result.ViewData.Model; //Assert value.Should().Be(ViewComponentTestHelper.GetPropertyValue(resultModel, key)); }
public static async Task <ListModel <Jobcategory> > GetFilterBy(string keyword, int pagenum = 1, int pagesize = Pager.DEFAULT_PAGE_SIZE, Sort sort = null) { ListModel <Jobcategory> l = new ListModel <Jobcategory>(); if (sort == null) { sort = new Sort(DEFAULT_SORT_COLUMN, DEFAULT_SORT_DIR); } ISession se = NHibernateHelper.CurrentSession; ICriteria cr = se.CreateCriteria <Jobcategory>("jobcat"); GetFilterCriteria(cr, keyword); ICriteria crCount = se.CreateCriteria <Jobcategory>("jobcat"); GetFilterCriteria(crCount, keyword); int total = await Task.Run(() => { return(crCount.SetProjection(Projections.Count(Projections.Id())).UniqueResult <int>()); }); Pager pager = new Pager(total, pagenum, pagesize); int has_next = pager.HasNext ? 1 : 0; int has_prev = pager.HasPrev ? 1 : 0; GetOrder(sort, cr); cr.SetFirstResult(pager.LowerBound); cr.SetMaxResults(pager.PageSize); IList <Jobcategory> list = await Task.Run(() => { return(cr.List <Jobcategory>()); }); l.ItemMsg = pager.GetItemMessage(); l.HasNext = has_next; l.HasPrev = has_prev; l.NextPage = pager.PageNum + 1; l.PrevPage = pager.PageNum - 1; l.List = list; l.SortColumn = sort.Column; l.SortDir = sort.Direction; l.Page = pager.PageNum; l.TotalPage = pager.TotalPages; return(l); }
private Task <ListModel <AT1ReportItemDTO> > TapWithAgeValues(ListModel <AT1ReportItemDTO> bareResults) { var currentDate = _datetimeProvider.Now; bareResults.Items.ForEach(item => { if (item.Birthdate == null) { return; } var ageTuple = _dateTimeCalculationsDomainService.CalculateDifference(item.Birthdate.Value, currentDate); item.AgeInYears = ageTuple.Years; item.AgeInMonthsOverYears = ageTuple.Months; item.AgeInDaysOverMonths = ageTuple.Days; }); return(Task.FromResult(bareResults)); }
protected override WhereConditon ListWhereSql(ListCondition condition) { WhereConditon wcd = new WhereConditon(); wcd.DBPara = new Dictionary <string, object>(); ApproveListCondition acondition = condition as ApproveListCondition; if (DataConvert.ToString(acondition.ListMode) != "") { wcd.DBPara.Add("approver", acondition.Approver); } ListModel model = JsonHelper.Deserialize <ListModel>(acondition.ListModelString); if (model == null) { return(wcd); } if (DataConvert.ToString(model.AssetsTransferNo) != "") { wcd.Sql += @" and M.assetsTransferNo like '%'+@assetsTransferNo+'%'"; wcd.DBPara.Add("assetsTransferNo", model.AssetsTransferNo); } if (DataConvert.ToString(model.AssetsTransferName) != "") { wcd.Sql += @" and M.assetsTransferName like '%'+@assetsTransferName+'%'"; wcd.DBPara.Add("assetsTransferName", model.AssetsTransferName); } if (DataConvert.ToString(model.TransferDate1) != "") { wcd.Sql += @" and exists (select 1 from AssetsTransferDetail where AssetsTransferDetail.assetsTransferId=M.assetsTransferId and AssetsTransferDetail.transferDate>=@transferDate1)"; wcd.DBPara.Add("transferDate1", DataConvert.ToString(model.TransferDate1) + " 00:00:00"); } if (DataConvert.ToString(model.TransferDate2) != "") { wcd.Sql += @" and exists(select 1 from AssetsTransferDetail where AssetsTransferDetail.assetsTransferId=M.assetsTransferId and AssetsTransferDetail.transferDate<=@transferDate2)"; wcd.DBPara.Add("transferDate2", DataConvert.ToString(model.TransferDate2) + " 23:59:59"); } if (DataConvert.ToString(model.ApproveState) != "") { wcd.Sql += @" and M.ApproveState_val=@ApproveState"; wcd.DBPara.Add("ApproveState", model.ApproveState); } return(wcd); }
public void BadCustomerId_ReturnsNull() { // arrange IMandatoryItemsListLogic testunit = MakeTestsObject(); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "223456" }; UserProfile fakeUser = new UserProfile(); // act ListModel results = testunit.ReadList(fakeUser, testcontext, false); // assert results.Should() .BeNull(); }
public static void Main() { var people = ListModel.FromSeq(new[] { "John", "Paul" }); var newName = Var.Create(""); var routed = new RouteMapBuilder() .With <Home>((go, _) => { var first = Var.Create("John"); var last = Var.Create("Doe"); var age = Var.Create(20); return(div( input(first), input(last), input(age), button("Go", () => go(new Person(new Name(first.Value, last.Value), age.Value == 0 ? null : (int?)age.Value))) )); }) .With <Person>((go, p) => div(p.Name.First, " ", p.Name.Last, p.Age == null ? " won't tell their age!" : $" is {p.Age} years old!", button("Back", () => go(new Home())) ) ) .With <People>((go, p) => ul(p.people.Select(x => li(x.First, " ", x.Last)).ToArray()) ) .Install(); div( h1("My list of unique people"), ul(people.View.DocSeqCached((string x) => li(x))), div( input(newName, attr.placeholder("Name")), button("Add", () => { people.Add(newName.Value); newName.Value = ""; }), div(newName.View) ), h1("Routed element:"), routed ).RunById("main"); }
public void AnyCustomerIdAndBranch_WhenIsDeleteIsTrueDeleteIsCalledWithListItemId() { // arrange Mock <IFavoriteListHeadersRepository> mockHeaderRepo = new Mock <IFavoriteListHeadersRepository>(); Mock <IFavoriteListDetailsRepository> mockDetailsRepo = new Mock <IFavoriteListDetailsRepository>(); FavoritesListLogicImpl testunit = new FavoritesListLogicImpl(mockDetailsRepo.Object, mockHeaderRepo.Object); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "123456" }; UserProfile fakeUser = new UserProfile(); ListModel testList = new ListModel { ListId = 1, CustomerNumber = "123456", BranchId = "FUT", Name = "Favorites", IsContractList = false, ReadOnly = false, IsFavorite = true, IsWorksheet = false, IsReminder = false, IsShared = false, IsSharing = false, IsMandatory = false, IsRecommended = false, Items = new List <ListItemModel> { new ListItemModel { Active = true, ListItemId = 2, IsDelete = true, CatalogId = "FDF", ItemNumber = "123456" } } }; // act testunit.SaveList(fakeUser, testcontext, testList); // assert - Always returns what is setup provided the mock is called mockDetailsRepo.Verify( x => x.SaveFavoriteListDetail(It.Is <FavoritesListDetail>(d => d.Active.Equals(false))), Times.Once(), "Error updating"); }
public ResResultModel GetOrderProcessList(ListModel model) { try { if (model.PageIndex < 1) { model.PageIndex = 1; } if (model.PageSize < 1) { model.PageSize = 10; } int totalRecord = 0; var bll = new OrderProcess(); StringBuilder sqlWhere = null; ParamsHelper parms = null; var orderId = Guid.Empty; if (model.ParentId != null && Guid.TryParse(model.ParentId.ToString(), out orderId)) { sqlWhere = new StringBuilder(100); parms = new ParamsHelper(); sqlWhere.Append("and OrderId = @OrderId "); var parm = new SqlParameter("@OrderId", SqlDbType.UniqueIdentifier); parm.Value = orderId; parms.Add(parm); } if (!string.IsNullOrWhiteSpace(model.Keyword)) { sqlWhere = new StringBuilder(50); parms = new ParamsHelper(); sqlWhere.Append("and o.OrderCode = @OrderCode "); var parm = new SqlParameter("@OrderCode", SqlDbType.VarChar, 20); parm.Value = model.Keyword; parms.Add(parm); } var list = bll.GetListByJoin(model.PageIndex, model.PageSize, out totalRecord, sqlWhere == null ? null : sqlWhere.ToString(), parms == null ? null: parms.ToArray()); return(ResResult.Response(true, "", "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}")); } catch (Exception ex) { return(ResResult.Response(false, ex.Message, "")); } }
public void BadCustomerId_ReturnsNull() { // arrange IContractListLogic logic = MakeMockLogic(); UserSelectedContext test = new UserSelectedContext { BranchId = "FUT", CustomerId = "999999" }; UserProfile fakeUser = new UserProfile(); int fakeId = 1; // act ListModel results = logic.GetListModel(fakeUser, test, fakeId); // assert results.Should() .BeNull(); }
public ListModel GetListModel(UserProfile user, UserSelectedContext catalogInfo, long Id) { ListModel list = null; HistoryListHeader header = _headerRepo.GetHistoryListHeader(catalogInfo); if (header == null) { list = null; } else { List <HistoryListDetail> items = _detailRepo.GetAllHistoryDetails(header.Id); list = header.ToListModel(items); } return(list); }
public string GetUserList(ListModel model) { try { var totalRecord = 0; var users = Membership.GetAllUsers((model.PageIndex - 1), model.PageSize, out totalRecord); var list = new List <ComboboxInfo>(); foreach (MembershipUser user in users) { list.Add(new ComboboxInfo(user.ProviderUserKey.ToString(), user.UserName)); } return(ResponseResult.Response(true, "", "{\"total\":" + totalRecord + ",\"rows\":" + JsonConvert.SerializeObject(list) + "}")); } catch (Exception ex) { return(ResponseResult.Response(false, ex.Message, "")); } }
/// <summary> /// Returns a list of the most recent posts /// </summary> /// <param name="helper"></param> /// <param name="masterModel"></param> /// <param name="count"></param> /// <returns></returns> public static IEnumerable <PostModel> GetRecentPosts(this UmbracoHelper helper, IMasterModel masterModel, int count) { var listNode = masterModel.RootBlogNode.Children .FirstOrDefault(x => x.DocumentTypeAlias.InvariantEquals("ArticulateArchive")); if (listNode == null) { throw new InvalidOperationException("An ArticulateArchive document must exist under the root Articulate document"); } var pager = new PagerModel(count, 0, 1); var listItems = helper.GetPostsSortedByPublishedDate(listNode.Id, pager); var rootPageModel = new ListModel(listNode, listItems, pager); return(rootPageModel.Children <PostModel>()); }
public async Task DeleteList_ShouldCallListRepositoryDelete() { // Data var listModel = new ListModel { Name = "todo list" }; // Setup _mockListRepository.Setup(x => x.Delete(listModel.Id, listModel.UserId)) .Returns(Task.CompletedTask).Verifiable(); // Test var listService = new ListService(_mockListRepository.Object); await listService.DeleteList(listModel.Id, listModel.UserId); // Analysis _mockListRepository.Verify(); }
public async Task UpdateList_ShouldCallListRepositoryUpdate() { // Data var listModel = new ListModel { Name = "todo list" }; // Setup _mockListRepository.Setup(x => x.Update(It.Is <Data.Entities.List>(y => y.Name == listModel.Name))) .Returns(Task.CompletedTask).Verifiable(); // Test var listService = new ListService(_mockListRepository.Object); await listService.UpdateList(listModel); // Analysis _mockListRepository.Verify(); }
protected override WhereConditon ListWhereSql(ListCondition condition) { WhereConditon wcd = new WhereConditon(); wcd.DBPara = new Dictionary <string, object>(); ListModel model = JsonHelper.Deserialize <ListModel>(condition.ListModelString); if (model == null) { return(wcd); } if (DataConvert.ToString(model.DepreciationRuleNo) != "") { wcd.Sql += @" and DepreciationRule.depreciationRuleNo like '%'+@depreciationRuleNo+'%'"; wcd.DBPara.Add("depreciationRuleNo", model.DepreciationRuleNo); } return(wcd); }
public void BadCustomerId_ReturnsNull() { // arrange IContractListLogic logic = MakeMockLogic(); UserSelectedContext test = new UserSelectedContext { BranchId = "FUT", CustomerId = "999999" }; UserProfile fakeUser = new UserProfile(); bool headerOnly = false; // act ListModel results = logic.ReadList(fakeUser, test, headerOnly); // assert results.Should() .BeNull(); }
public ListModel GetListModel(UserProfile user, UserSelectedContext catalogInfo, long id) { ListModel list = null; ContractListHeader header = _headersRepo.GetListHeaderForCustomer(catalogInfo); if (header != null) { List <ContractListDetail> items = _detailsRepo.GetContractListDetails(header.Id); list = header.ToListModel(items); } else { list = null; } return(list); }
public void GoodCustomerIdAndBranch_ReturnsExpectedList() { // arrange IInventoryValuationListLogic testunit = MakeTestsObject(); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "123456" }; int expectedListId = 1; // act ListModel results = testunit.ReadList(expectedListId, testcontext, false); // assert results.ListId .Should() .Be(expectedListId); }
public ListModel <AnnotationTaskModel> QueryByWhere(PredicateBuilder <AnnotationTask> where, int page, int size) { ListModel <AnnotationTaskModel> listModel = new ListModel <AnnotationTaskModel>(); var taskList = _db.AnnotationTask.Where(where.Expression).AsNoTracking().ToPagedList(page, size); if (taskList.Count > 0) { listModel.list = _mapper.Map <List <AnnotationTaskModel> >(taskList.Items); listModel.count = taskList.TotalItemCount; listModel.page = page; listModel.size = size; return(listModel); } else { return(null); } }
public bool AddRecord(DataTable dt, ListModel model) { try { DataRow row = dt.NewRow(); row["ItemName"] = model.ItemName; row["ItemPrice"] = model.ItemPrice; row["ItemQuantity"] = model.ItemQuantity; row["Taxable"] = model.Taxable ? "T" : string.Empty; dt.Rows.Add(row); return(true); } catch (Exception) { return(false); } }
protected override WhereConditon ListWhereSql(ListCondition condition) { WhereConditon wcd = new WhereConditon(); wcd.DBPara = new Dictionary <string, object>(); ListModel model = JsonHelper.Deserialize <ListModel>(condition.ListModelString); if (model == null) { return(wcd); } if (DataConvert.ToString(model.BarcodeStyleName) != "") { wcd.Sql += @" and BarcodeStyle.barcodeStyleName like '%'+@barcodeStyleName+'%'"; wcd.DBPara.Add("barcodeStyleName", model.BarcodeStyleName); } return(wcd); }
public void BadCustomerId_ReturnsNull() { // arrange IFavoritesListLogic testunit = MakeTestsUnit(); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "223456" }; UserProfile fakeUser = new UserProfile(); int fakeId = 0; // act ListModel results = testunit.GetListModel(fakeUser, testcontext, fakeId); // assert results.Should() .BeNull(); }
public void BadCustomerId_ReturnsNull() { // arrange IRecentlyOrderedListLogic testunit = MakeTestsObject(); UserSelectedContext testcontext = new UserSelectedContext { BranchId = "FUT", CustomerId = "223456" }; UserProfile fakeUser = new UserProfile(); bool headerOnly = false; // act ListModel results = testunit.ReadList(fakeUser, testcontext, headerOnly); // assert results.Should() .BeNull(); }
public void ChangeControllableCharacter(int id) { var player = this.GetModelById(id); player.IsBeingControllable = false; var nextPlayer = new Models.PlayerViewModel(); var index = ListModel.IndexOf(player) + 1; if (ListModel.Count > index) { nextPlayer = ListModel[index]; } else { nextPlayer = ListModel.First(); } nextPlayer.IsBeingControllable = true; }
public static List <ListModel> GetTransactionType() { List <ListModel> list = new List <ListModel>(); ListModel ListModel = new ListModel(); ListModel.Value = "Credit"; ListModel.Text = "Credit"; list.Add(ListModel); ListModel ListModel2 = new ListModel(); ListModel2.Value = "Debit"; ListModel2.Text = "Debit"; list.Add(ListModel2); return(list); }
public static async Task<ListModel<Attendance>> GetFilterBy(Dictionary<string, object> filters, int pagenum = 1, int pagesize = Pager.DEFAULT_PAGE_SIZE, Sort sort = null) { ListModel<Attendance> l = new ListModel<Attendance>(); if (sort == null) sort = new Sort(DEFAULT_SORT_COLUMN, DEFAULT_SORT_DIR); ISession se = NHibernateHelper.CurrentSession; ICriteria cr = se.CreateCriteria<Attendance>("attendance"); GetFilterCriteria(cr, filters, sort); ICriteria crCount = se.CreateCriteria<Attendance>("attendance"); GetFilterCriteria(crCount, filters, sort); int total = crCount.SetProjection(Projections.Count(Projections.Id())).UniqueResult<int>(); Pager pager = new Pager(total, pagenum, pagesize); int has_next = pager.HasNext ? 1 : 0; int has_prev = pager.HasPrev ? 1 : 0; GetOrder(sort, cr); cr.SetFirstResult(pager.LowerBound); cr.SetMaxResults(pager.PageSize); IList<Attendance> list = await Task.Run(() => { return cr.List<Attendance>(); }); l.ItemMsg = pager.GetItemMessage(); l.HasNext = has_next; l.HasPrev = has_prev; l.NextPage = pager.PageNum + 1; l.PrevPage = pager.PageNum - 1; l.List = list; l.SortColumn = sort.Column; l.SortDir = sort.Direction; l.Page = pager.PageNum; l.TotalPage = pager.TotalPages; return l; }
public static async Task<ListModel<Employee>> GetAll(int pagenum = 1, int pagesize = Pager.DEFAULT_PAGE_SIZE, Sort sort = null) { ListModel<Employee> l = new ListModel<Employee>(); if (sort == null) sort = new Sort(DEFAULT_SORT_COLUMN, DEFAULT_SORT_DIR); ISession se = NHibernateHelper.CurrentSession; int total = await Task.Run(() => { return se.QueryOver<Employee>().Future().Count(); }); Pager pager = new Pager(total, pagenum, pagesize); int has_next = pager.HasNext ? 1 : 0; int has_prev = pager.HasPrev ? 1 : 0; ICriteria cr = se.CreateCriteria<Employee>("employee"); if (sort.Column == "d.Title" || sort.Column == "es.Name" || sort.Column == "dept.Name") SetJoinCriteria(cr, sort); GetOrder(sort, cr); cr.SetFirstResult(pager.LowerBound); cr.SetMaxResults(pager.PageSize); IList<Employee> list = await Task.Run(() => { return cr.List<Employee>(); }); l.ItemMsg = pager.GetItemMessage(); l.HasNext = has_next; l.HasPrev = has_prev; l.NextPage = pager.PageNum + 1; l.PrevPage = pager.PageNum - 1; l.List = list; l.SortColumn = sort.Column; l.SortDir = sort.Direction; l.Page = pager.PageNum; l.TotalPage = pager.TotalPages; return l; }
/// <summary> /// Creates a list that displays the elements in the specified model. /// </summary> /// <param name="listModel"></param> public G2DList(ListModel listModel) : base() { if (listModel == null) throw new ArgumentException("listModel has to be non-null value"); this.listModel = listModel; selectionModel = new DefaultListSelectionModel(); cellRenderer = new DefaultListCellRenderer(); backgroundColor = Color.White; selectionBackgroundColor = Color.SkyBlue; selectionForegroundColor = Color.White; pressedKeys = new List<Keys>(); scrollableTracksViewportHeight = false; scrollableTracksViewportWidth = false; name = "G2DList"; }
public void TodoApp() { var Tasks = new ListModel<string, TaskItem>(task => task.Name) { new TaskItem("Have breakfast", true), new TaskItem("Have lunch", false) }; var NewTaskName = Var.Create(""); Template.Template.Main.Doc( ListContainer: Tasks.View.DocSeqCached((TaskItem task) => Template.Template.ListItem.Doc( Task: task.Name, Clear: (el, ev) => Tasks.RemoveByKey(task.Name), Done: task.Done, ShowDone: attr.@class("checked", task.Done.View, x => x) ) ), NewTaskName: NewTaskName, Add: (el, ev) => { Tasks.Add(new TaskItem(NewTaskName.Value, false)); NewTaskName.Value = ""; }, ClearCompleted: (el, ev) => Tasks.RemoveBy(task => task.Done.Value) ).RunById("tasks"); }
public DemoForm() { this.InitializeComponent(); // Generate some test / demo objects this.objA = new Test(); this.objA.IPropWithAVeryLongName = 42; this.objA.SomeString = "Blubdiwupp"; this.objA.SomeFloat = (float)Math.PI; this.objA.SomeByte = 128; this.objA.Substruct = new Test2(42); this.objA.ReflectedTypeTestA = new Test3[] { new Test3() }; this.objA.ReflectedTypeTestB = new Dictionary<string,object> { { "First", new Test3() } }; this.objA.stringListField = new List<string>() { "hallo", "welt" }; this.objB = new Test(); this.objB.IPropWithAVeryLongName = 17; this.objB.SomeString = "Kratatazong"; this.objB.SomeFloat = 3.0f; this.objB.SomeByte = 0; this.objB.Substruct = new Test2(100); this.objB.stringListField = new List<string>() { "hallo", "welt" }; this.propertyGrid1.SelectObject(this.objA); this.tiledViewModel = new ListModel<TiledModelItem>(); this.tiledViewModel.Add(new TiledModelItem { Name = "Frederick" }); this.tiledViewModel.Add(new TiledModelItem { Name = "Herbert" }); this.tiledViewModel.Add(new TiledModelItem { Name = "Mary" }); this.tiledViewModel.Add(new TiledModelItem { Name = "John" }); this.tiledViewModel.Add(new TiledModelItem { Name = "Sally" }); this.tiledView.Model = this.tiledViewModel; this.tiledView.ItemAppearance += this.tiledView_ItemAppearance; this.timelineViewModel = new TimelineModel(); this.timelineView1.Model = this.timelineViewModel; { TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track A" }; graphTrack.Add(new TimelineLinearGraphModel(new TimelineLinearGraphModel.Key[] { new TimelineLinearGraphModel.Key(0.0f, 1.0f), new TimelineLinearGraphModel.Key(10.0f, 0.75f), new TimelineLinearGraphModel.Key(15.0f, 0.5f), new TimelineLinearGraphModel.Key(20.0f, 0.0f), new TimelineLinearGraphModel.Key(25.0f, -0.5f), new TimelineLinearGraphModel.Key(30.0f, -0.75f), new TimelineLinearGraphModel.Key(40.0f, -1.0f), new TimelineLinearGraphModel.Key(50.0f, 5.0f) })); this.timelineViewModel.Add(graphTrack); } { Func<float,float> func = x => (float)Math.Sin(0.005f * x * x); TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track B" }; graphTrack.Add(new TimelineFunctionGraphModel( x => func(x), delegate (float a, float b) { float result = Math.Min(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Min(result, func(x)); if (result <= -1.0f) break; } return result; }, delegate (float a, float b) { float result = Math.Max(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Max(result, func(x)); if (result >= 1.0f) break; } return result; }, 0.0f, 500.0f)); this.timelineViewModel.Add(graphTrack); } { Func<float,float> func = x => (float)Math.Sin(0.005f * x * x) * (float)(0.5f + 0.5f * Math.Sin(0.1f * x)); TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track C" }; graphTrack.Add(new TimelineFunctionGraphModel( x => func(x), delegate (float a, float b) { float result = Math.Min(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Min(result, func(x)); if (result <= -1.0f) break; } return result; }, delegate (float a, float b) { float result = Math.Max(func(a), func(b)); int intervalIndexA = 1 + (int)((0.005f * a * a / (float)Math.PI) - 0.5f); int intervalIndexB = (int)((0.005f * b * b / (float)Math.PI) - 0.5f); for (int i = intervalIndexA; i <= intervalIndexB; i++) { float x = (float)Math.Sqrt((i + 0.5d) * Math.PI / 0.005d); result = Math.Max(result, func(x)); if (result >= 1.0f) break; } return result; }, 0.0f, 1500.0f)); this.timelineViewModel.Add(graphTrack); } { TimelineGraphTrackModel graphTrack = new TimelineGraphTrackModel { TrackName = "Track D" }; graphTrack.Add(new TimelineLinearGraphModel(Enumerable.Range(0, 360).Select(i => 0.5f + (float)Math.Sin((float)i * Math.PI / 180.0f)), 1.0f, 0.0f)); graphTrack.Add(new TimelineLinearGraphModel(Enumerable.Range(0, 360).Select(i => (float)Math.Sin((float)i * Math.PI / 180.0f)), 1.0f, 50.0f)); this.timelineViewModel.Add(graphTrack); } }
public override void Update(bool force) { //Don't do anything here... Model = new ListModel<RepositoryDetailedModel>() { Data = new List<RepositoryDetailedModel>() }; }
public override void Update(bool force) { Model = new ListModel<RepositoryDetailedModel> { Data = Application.Client.Account.GetRepositories(force) }; }