public async Task GetAllPerPageAsyncShouldReturnCorrectModelCollectionWhenCreatorIdIsPassed() { var creatorId = Guid.NewGuid().ToString(); await this.CreateGroupAsync(null, "First Group"); var secondGroupId = await this.CreateGroupAsync(creatorId, "Second Group"); var secondModel = new GroupListViewModel() { Id = secondGroupId, Name = "Second Group", StudentsCount = 0, EventsCount = 0, }; var resultModelCollection = await this.Service.GetAllPerPageAsync <GroupListViewModel>(1, 2, creatorId); Assert.Single(resultModelCollection); Assert.IsAssignableFrom <IList <GroupListViewModel> >(resultModelCollection); Assert.Equal(secondModel.Id, resultModelCollection.First().Id); Assert.Equal(secondModel.Name, resultModelCollection.First().Name); Assert.Equal(secondModel.StudentsCount, resultModelCollection.First().StudentsCount); Assert.Equal(secondModel.EventsCount, resultModelCollection.First().EventsCount); }
protected override void OnCreate(Bundle savedInstanceState) { GroupViewModel = EngineService.EngineInstance.GroupListViewModel; base.OnCreate(savedInstanceState); toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); toolbar.Title = ""; fabNext = FindViewById <FloatingActionButton>(Resource.Id.fabNext); fabNext.Click += FabNext_Click; recyclerContacts = FindViewById <RecyclerView>(Resource.Id.recyclerContacts); recyclerSelected = FindViewById <RecyclerView>(Resource.Id.horizontalContainer); LinearLayoutManager layoutManager = new LinearLayoutManager(this); recyclerContacts.SetLayoutManager(layoutManager); recyclerContacts.SetItemAnimator(new DefaultItemAnimator()); chooseContactAdapter = new ChooseContactAdapter(this, GroupViewModel); recyclerContacts.SetAdapter(chooseContactAdapter); LinearLayoutManager horizontalManager = new LinearLayoutManager(this, LinearLayoutManager.Horizontal, false); recyclerSelected.SetLayoutManager(horizontalManager); recyclerSelected.SetItemAnimator(new DefaultItemAnimator()); selectedContactAdapter = new SelectedContactAdapter(this, GroupViewModel); recyclerSelected.SetAdapter(selectedContactAdapter); }
public ActionResult Groups() { var userGroups = _hermesDataContext.Groups.Where(x => x.IsActive); var groups = Mapper.Instance.Map <IEnumerable <UserGroupViewModel> >(userGroups); var usrs = _hermesDataContext.Users.Select(x => new SelectListItem { Text = x.FirstName + " " + x.LastName, Value = x.Id }).ToList(); var viewModel = new GroupListViewModel() { Groups = groups, Users = usrs, }; foreach (var group in viewModel.Groups) { foreach (var usGroup in group.UserGroups) { usGroup.ApplicationUser = _hermesDataContext.Users.Find(usGroup.ApplicationUserId); } } ViewBag.CurrentUser = CurrentUser; return(View(viewModel)); }
public void AddGroupMock() { var data = new List <Group> { new Group { GroupId = 1, GroupName = "Test", SoftDeleted = false }, new Group { GroupId = 2, GroupName = "Another", SoftDeleted = false } }.AsQueryable(); var mockSet = new Mock <DbSet <Group> >(); mockSet.As <IQueryable <Group> >().Setup(m => m.Provider).Returns(data.Provider); mockSet.As <IQueryable <Group> >().Setup(m => m.Expression).Returns(data.Expression); mockSet.As <IQueryable <Group> >().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As <IQueryable <Group> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); var mockContext = new Mock <StudentHostelContext>(); mockContext.Setup(c => c.Groups).Returns(mockSet.Object); var viewModel = new GroupListViewModel(mockContext.Object); viewModel.AddCommand.Execute(""); viewModel.CurrentGroup = new GroupViewModel { GroupId = 0, GroupName = "NewTest" }; viewModel.SaveCommand.Execute(""); var groups = viewModel.GroupList; Assert.AreEqual(3, groups.Count); Assert.AreEqual("NewTest", groups[2].GroupName); }
public void GetAllGroupsMock() { var data = new List <Group> { new Group { GroupId = 1, GroupName = "Test", SoftDeleted = false }, new Group { GroupId = 2, GroupName = "Another", SoftDeleted = false }, new Group { GroupId = 3, GroupName = "Deleted", SoftDeleted = true } }.AsQueryable(); var mockSet = new Mock <DbSet <Group> >(); mockSet.As <IQueryable <Group> >().Setup(m => m.Provider).Returns(data.Provider); mockSet.As <IQueryable <Group> >().Setup(m => m.Expression).Returns(data.Expression); mockSet.As <IQueryable <Group> >().Setup(m => m.ElementType).Returns(data.ElementType); mockSet.As <IQueryable <Group> >().Setup(m => m.GetEnumerator()).Returns(data.GetEnumerator()); var mockContext = new Mock <StudentHostelContext>(); mockContext.Setup(c => c.Groups).Returns(mockSet.Object); var viewModel = new GroupListViewModel(mockContext.Object); var groups = viewModel.GroupList; Assert.AreEqual(2, groups.Count); Assert.AreEqual("Test", groups[0].GroupName); Assert.AreEqual("Another", groups[1].GroupName); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { GroupListViewModel = EngineService.EngineInstance.GroupListViewModel; var rootView = inflater.Inflate(Resource.Layout.fragment_group_selectcontact, container, false); fabNext = rootView.FindViewById <FloatingActionButton>(Resource.Id.fabNext); fabNext.Click += FabNext_Click; recyclerContacts = rootView.FindViewById <RecyclerView>(Resource.Id.recyclerContacts); recyclerSelected = rootView.FindViewById <RecyclerView>(Resource.Id.horizontalContainer); LinearLayoutManager layoutManager = new LinearLayoutManager(ParentActivity); recyclerContacts.SetLayoutManager(layoutManager); recyclerContacts.SetItemAnimator(new DefaultItemAnimator()); chooseContactAdapter = new ChooseContactAdapter(ParentActivity, GroupListViewModel); recyclerContacts.SetAdapter(chooseContactAdapter); LinearLayoutManager horizontalManager = new LinearLayoutManager(ParentActivity, LinearLayoutManager.Horizontal, false); recyclerSelected.SetLayoutManager(horizontalManager); recyclerSelected.SetItemAnimator(new DefaultItemAnimator()); selectedContactAdapter = new SelectedContactAdapter(this.ParentActivity, GroupListViewModel); recyclerSelected.SetAdapter(selectedContactAdapter); return(rootView); }
public ActionResult List(string GroupName = "", int PageIndex = 1, int PageSize = 10) { try { //初始化物件 var m = new GroupListViewModel(); m.Authority = Tool.GetPageAuthority(); m.Parameters = new QueryParameter(); m.Pages = new Pages(); //設定參數 m.Parameters.GroupName = GroupName; m.Pages.PageIndex = PageIndex; m.Pages.PageSize = PageSize; //清單資料 var dtGroup = GroupDataAccess.GetGroupList(null, m.Parameters.GroupName, m.Pages); m.List = Util.ToList <ListItem>(dtGroup); return(View(m)); } catch { return(RedirectToAction("Error", "Home")); } }
public ActionResult Categories(string id, int page = 1) { using (var db = new DatabaseContext()) { ViewModels viewModel = new ViewModels(); GroupListViewModel groupList = new GroupListViewModel(); Kategoria category = db.Kategoria.FirstOrDefault(p => p.Skrot == id); if (category == null) { return(View("Error", new string[] { "Nie ma kategorii o podanej nazwie" })); } groupList.Groups = (db.KoloNaukowe.Where(p => p.KategoriaId == category.Id). OrderBy(p => p.Id).Skip((page - 1) * PageSize).Take(PageSize)).ToList(); if (groupList.Groups == null) { return(View("Error", new string[] { "Brak kół w kategorii" })); } int totalItems = db.KoloNaukowe.Where(p => p.KategoriaId == category.Id).Count(); groupList.Pages = (int)Math.Ceiling((decimal)totalItems / PageSize); groupList.CurrentPage = page; groupList.Category = id; groupList.CategoryName = category.Nazwa; groupList = SetDetails(groupList); viewModel.GroupList = groupList; return(View(viewModel)); } }
public async Task <IActionResult> Index(string activeTabGroupId) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var businessId = this.HttpContext.Items[GlobalConstants.BusinessIdSessionName].ToString(); var groups = await this.groupService.GetAllGroupByCurrentUserAndBusinessIdAsync <GroupPeopleCountViewModel>(businessId, userId); var specialGroups = groups .Where(x => x.Name == GlobalConstants.AdminsGroupName || x.Name == GlobalConstants.HrGroupName || x.Name == GlobalConstants.ScheduleManagersGroupName); groups = groups.Where(x => x.Name != GlobalConstants.AdminsGroupName && x.Name != GlobalConstants.HrGroupName && x.Name != GlobalConstants.ScheduleManagersGroupName); var viewModel = new GroupListViewModel <GroupPeopleCountViewModel>() { Groups = groups, SpecialGroups = specialGroups, ActiveTabGroupId = activeTabGroupId ?? groups.FirstOrDefault()?.Id, IsInHrOrAdminRoleGroup = await this.employeeGroupService.IsEmployeeInGroupsWithNames(userId, businessId, GlobalConstants.AdminsGroupName, GlobalConstants.HrGroupName), }; return(this.View(viewModel)); }
public void AddGroupEffort() { var connection = DbConnectionFactory.CreateTransient(); var context = new StudentHostelContext(connection); GroupListViewModel viewModel = new GroupListViewModel(context); // Определяем текущее количество записей в таблице int count = viewModel.GroupList.Count; viewModel.AddCommand.Execute(""); viewModel.CurrentGroup = new GroupViewModel { GroupId = 0, GroupName = "Test" }; viewModel.SaveCommand.Execute(""); // Получаем добавленную запись var group = context.Groups.Where(p => p.GroupId == count + 1).FirstOrDefault(); // Проверяем, что количество записей в таблице увеличилось на 1 Assert.AreEqual(count + 1, context.Groups.Count()); Assert.AreEqual(count + 1, viewModel.GroupList.Count); // Проверяем поле GroupId новой записи Assert.AreEqual(count + 1, group.GroupId); Assert.AreEqual(count + 1, viewModel.GroupList[count].GroupId); // Проверяем поле GroupName новой записи Assert.AreEqual("Test", group.GroupName); Assert.AreEqual("Test", viewModel.GroupList[count].GroupName); }
public async Task <BaseResponse> GetGroupsAsync(GroupListRequest req) { GroupListViewModel rm = new GroupListViewModel(); //根据要查找的字段进行查找 Expression <Func <GroupModel, bool> > predicate; if (string.IsNullOrWhiteSpace(req.Field) || string.IsNullOrWhiteSpace(req.FieldValue)) { predicate = a => true; } else { predicate = LinqHelper <GroupModel> .Contains(req.Field, req.FieldValue); } var groups = _group.Find(predicate); if (req.OrderType.ToUpper() == "ASC") { groups = groups.OrderBy(LinqHelper <GroupModel> .Order <string>(req.OrderField /*a => a.GetType().GetProperty(req.OrderField)*/)); } else { groups = groups.OrderByDescending(LinqHelper <GroupModel> .Order <string>(req.OrderField)); } var gml = await groups.ToListAsync(); foreach (var item in gml) { //rm.Data.Add(new GroupData() { Id = item.Id, Code = item.Code, Description = item.Description, Logo = item.Logo, Name = item.Name }); } rm.Success = true; rm.Message = "获取数据成功"; return(rm); }
protected override void OnCreate(Bundle savedInstanceState) { GroupViewModel = EngineService.EngineInstance.GroupListViewModel; base.OnCreate(savedInstanceState); toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); imgProfile = FindViewById <ImageView>(Resource.Id.imgProfile); fab = FindViewById <FloatingActionButton>(Resource.Id.fab); txtTotalIndicator = FindViewById <TextView>(Resource.Id.txtTotalIndicator); txtTotalCount = FindViewById <TextView>(Resource.Id.txtTotalCount); txtAdminIndicator = FindViewById <TextView>(Resource.Id.txtAdminIndicator); txtAdminName = FindViewById <TextView>(Resource.Id.txtAdminName); txtGroupName = FindViewById <TextView>(Resource.Id.txtGroupName); txtGroupNameIndicator = FindViewById <TextView>(Resource.Id.txtGroupNameIndicator); recyclerMember = FindViewById <RecyclerView>(Resource.Id.recyclerContacts); var linearLayoutManager = new CustomLinearLayoutManager(this); linearLayoutManager.setScrollEnabled(false); recyclerMember.SetLayoutManager(linearLayoutManager); adapter = new GroupEditAdapter(this, new List <UserDTO>()); recyclerMember.SetAdapter(adapter); btEditGroupName = FindViewById <ImageButton>(Resource.Id.btEditGroupName); btLeaveGroup = FindViewById <Button>(Resource.Id.btLeaveGroup); btAddMember = FindViewById <Button>(Resource.Id.btAddMember); btEditGroupName.Click += BtEditGroupName_Click; fab.Click += ChangePhoto_Click; btAddMember.Click += BtAddMember_Click; btLeaveGroup.Click += BtLeaveGroup_Click; }
public GroupListViewModel FindByName(string name) { GroupListViewModel glvm = new GroupListViewModel(); glvm = gs.GetGroupList(name); return(glvm); }
public void OnGroupSelect() { AddLog("Chọn nhóm"); var vm = new GroupListViewModel(this) { ShowButtons = false }; var view = new NovaAlert.Config.Views.GroupListView() { DataContext = vm, Width = 400, Height = 300 }; if (NovaAlert.Common.Wpf.ModalDialog.ShowControl(view, "Chọn nhóm đơn vị") == true) { if (vm.ItemSelected != null) { var groupId = vm.ItemSelected.GroupObj.Id; if (groupId != this.GroupId) { this.GroupId = groupId; AddLog(string.Format("Chọn nhóm {0}", this.GroupId)); ClientSetting.Instance.Save(); } } } }
public SelectedContactAdapter(Activity Activity, GroupListViewModel ViewModel) { this.ViewModel = ViewModel; this.Activity = Activity; this.ViewModel.ChoosedContactList.CollectionChanged += (sender, e) => { Activity.RunOnUiThread(() => { NotifyDataSetChanged(); }); }; }
void InitChatViewService() { if (EngineService.EngineInstance.GroupListViewModel != null) { ViewModel = EngineService.EngineInstance.GroupListViewModel; ViewModel.GroupChatHistoryItemList.Clear(); } }
public ChooseContactAdapter(Activity Activity, GroupListViewModel GroupListViewModel) { this.Activity = Activity; this.ViewModel = GroupListViewModel; GroupListViewModel.ChoosableContactList.CollectionChanged += (sender, e) => { this.Activity.RunOnUiThread(NotifyDataSetChanged); }; }
public ActionResult Index(GroupListViewModel viewModel) { viewModel.GroupViewModels = this._groupManager .GetAll(this.GetInstitutionID) .Select(GroupMapper.ToViewModelExpression) .ToList(); return View(viewModel); }
public ActionResult Index() { var groupListViewModel = new GroupListViewModel() { List = groupManager.GetAll().Select(group => new GroupViewModel(group)) }; return(View(groupListViewModel)); }
private void updateContext(GroupListViewModel g) { if (g == null) { return; } glvm = g; GIUCGrid.DataContext = g; datagrid.ItemsSource = g.Table.DefaultView; }
public ActionResult Index() { GroupListViewModel model = new GroupListViewModel(); TryUpdateModel(model); model.Entities = groupRepo.GetAll(g => g.UserID == AuthenticationService.LoggedUser.Id); return(View(model)); }
public GroupListAdapter(Activity ParentActivity, GroupListViewModel ViewModel) { this.ParentActivity = ParentActivity; this.ViewModel = ViewModel; ViewModel.Items.CollectionChanged += (sender, args) => { this.ParentActivity.RunOnUiThread(NotifyDataSetChanged); }; }
protected override void OnStart() { base.OnStart(); if (GroupViewModel == null) { EngineService.EngineInstance.GroupListViewModel = new GroupListViewModel(); GroupViewModel = EngineService.EngineInstance.GroupListViewModel; } GroupViewModel.PropertyChanged += GroupViewModel_PropertyChanged; ShowHideNecessaryItem(); InitViews(); }
// GET: Events public ActionResult Index() { GroupRepository repository = new GroupRepository(); List <Group> groups = repository.GetAll(); groups.Reverse(); GroupListViewModel model = new GroupListViewModel(); model.Groups = groups; return(View(model)); }
protected override void OnCreate(Bundle savedInstanceState) { ViewModel = EngineService.EngineInstance.GroupListViewModel; ViewModel.ChoosableContactList.Clear(); ViewModel.ChoosedContactList.Clear(); base.OnCreate(savedInstanceState); toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); txtPrimaryToolbar = FindViewById <TextView>(Resource.Id.txtPrimaryToolbar); txtSecondaryToolbar = FindViewById <TextView>(Resource.Id.txtDescriptionToolbar); SetFragment(FRAGMENT_CHOOSE_CONTACT); }
public async Task <IActionResult> All(string activeTabGroupId) { var userId = this.User.FindFirst(ClaimTypes.NameIdentifier)?.Value; var businessId = await this.HttpContext.Session.GetStringAsync(GlobalConstants.BusinessIdSessionName); var groupsInBusiness = await this.groupService.GetAllGroupByCurrentUserAndBusinessIdAsync <GroupBasicInfoViewModel>(businessId, userId, true, PendingActionsType.ShiftApplications); var viewModel = new GroupListViewModel <GroupBasicInfoViewModel>() { Groups = groupsInBusiness, ActiveTabGroupId = activeTabGroupId ?? groupsInBusiness.FirstOrDefault()?.Id, }; return(this.View(viewModel)); }
public ActionResult Export(GroupListViewModel m) { //分頁物件,設定單頁筆數為最大值 Pages pages = new Pages(); pages.PageSize = int.MaxValue; //取回資料 var dt = GroupDataAccess.GetGroupList(null, m.Parameters.GroupName, pages); //轉為二進位資料流 var numList = new List <int>(); MemoryStream ms = NPOITools.RenderDataTableToExcel(dt, numList) as MemoryStream; return(File(ms.ToArray(), "application/vnd.ms-excel")); }
protected override void OnCreate(Bundle savedInstanceState) { GroupViewModel = EngineService.EngineInstance.GroupListViewModel; base.OnCreate(savedInstanceState); toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); SupportActionBar.SetDisplayHomeAsUpEnabled(true); SupportActionBar.SetHomeButtonEnabled(true); toolbar.Title = ""; txtStatusIndicator = FindViewById <TextView>(Resource.Id.txtStatusIndicator); txtGroupName = FindViewById <EditText>(Resource.Id.txtGroupName); btCancel = FindViewById <Button>(Resource.Id.btCancel); btDone = FindViewById <Button>(Resource.Id.btDone); btCancel.Click += (sender, e) => { Finish(); }; btDone.Click += BtDone_Click; }
public GroupListViewModel GetAll() { var vm = new GroupListViewModel { Accounts = dbContext.Users.Include(x => x.Billing).Select(x => new GroupItemListViewModel { Id = x.Id, FirstName = x.FirstName, LastName = x.LastName, Group = x.Group, Position = x.Position, HoursMinutesWorked = MinsToHoursMins(x.Billing.MinutesWorked), HourlyPay = x.Billing.HourlyPay }).OrderByDescending(x => x.Position).ToList() }; return(vm); }
public void EditGroupEffort() { var connection = DbConnectionFactory.CreateTransient(); var context = new StudentHostelContext(connection); GroupListViewModel viewModel = new GroupListViewModel(context); viewModel.CurrentGroup = viewModel.GroupList.Where(p => p.GroupId == 1).FirstOrDefault(); viewModel.EditCommand.Execute(""); viewModel.CurrentGroup.GroupName = "NewName"; viewModel.SaveCommand.Execute(""); // Получаем измененную запись Group group = context.Groups.Where(p => p.GroupId == 1).FirstOrDefault(); // Проверяем, что поле GroupName изменено Assert.AreEqual("NewName", group.GroupName); Assert.AreEqual("NewName", viewModel.CurrentGroup.GroupName); Assert.AreEqual("NewName", viewModel.GroupList[0].GroupName); }
void InitViewModels() { if (ContactListViewModel == null) { ContactListViewModel = new ContactListViewModel(); } if (ChatListViewModel == null) { ChatListViewModel = new ChatListViewModel(); } if (GroupListViewModel == null) { GroupListViewModel = new GroupListViewModel(); } if (ProfileViewModel == null) { ProfileViewModel = new ProfileViewModel(); } }
public ActionResult ListAllGroups() { List<GroupListViewModel> viewModels = new List<GroupListViewModel>(); //private int curUserId //{ // get { // try { // curUserId = db.Users.Single(s => s.UserName == User.Identity.Name).UserId; // } //catch { // curUserId = db.Admins.Single(s => s.AdminName == User.Identity.Name).AdminId; //} // } foreach (var group in db.Groups) { var viewModel = new GroupListViewModel() { GroupId = group.GroupId, GroupName = group.GroupName, //Password = group.Password, //CreatedBy = group.CreatedBy, //CreatedDate = group.CreatedDate, Status = group.Status, //ModifiedBy = group.ModifiedBy, //ModifiedDate = group.ModifiedDate, }; viewModels.Add(viewModel); } return View(viewModels); }