public ViewResult List()
        {
            var membersListViewModel = new MembersListViewModel
            {
                ActiveOnly = true
            };

            ViewBag.Title = "Members";
            return(View(membersListViewModel));
        }
        public ActionResult CheckMembers()
        {
            List <User> Users        = new List <User>();
            var         user_id      = (int)Session["user_id"];
            var         managerHouse =
                _Context.ManagerHouses.SingleOrDefault(mh => mh.User_Id == user_id && mh.IsActive == true);
            var houseKey   = _Context.HouseKeys.SingleOrDefault(hk => hk.Key == managerHouse.Key);
            var userHouses = _Context.UserHouses.Where(uh => uh.HouseKeyId == houseKey.Id && uh.IsActive == true)
                             .ToList();

            foreach (var x in userHouses)
            {
                Users.Add(_Context.Users.SingleOrDefault(u => u.UserId == x.UserId));
            }
            var membersList = new MembersListViewModel()
            {
                User = Users
            };

            return(View(membersList));
        }
        public void Can_Send_Pagnation_View_Model()
        {
            Mock <IMemberRepository> mock = new Mock <IMemberRepository>();

            mock.Setup(m => m.Members).Returns((new Member[]
            {
                new Member {
                    MemberId = "1", MemberName = "M1"
                },
                new Member {
                    MemberId = "2", MemberName = "M2"
                },
                new Member {
                    MemberId = "3", MemberName = "M3"
                },
                new Member {
                    MemberId = "4", MemberName = "M4"
                },
                new Member {
                    MemberId = "5", MemberName = "M5"
                }
            }).AsQueryable <Member>());

            // Arrange
            MemberController controller = new MemberController(mock.Object)
            {
                PageSize = 3
            };

            //Act
            MembersListViewModel result = controller.List(null, 2).ViewData.Model as MembersListViewModel;

            // Assert
            PagingInfo pageInfo = result.PagingInfo;

            Assert.Equal(2, pageInfo.CurrentPage);
            Assert.Equal(3, pageInfo.ItemsPerPage);
            Assert.Equal(5, pageInfo.TotalItems);
            Assert.Equal(2, pageInfo.TotalPages);
        }
Ejemplo n.º 4
0
        public ActionResult MembersList(string key)
        {
            List <User> Users = new List <User>();

            var houseKeyId = _Context.HouseKeys.SingleOrDefault(hk => hk.Key == key);

            var house = _Context.Houses.SingleOrDefault(h => h.Id == houseKeyId.HouseId);

            var members   = _Context.UserHouses.Where(mh => mh.HouseKeyId == houseKeyId.Id && mh.IsActive == true).ToList();
            var membersId = members.Select(m => m.UserId);

            foreach (var x in membersId)
            {
                Users.Add(_Context.Users.SingleOrDefault(u => u.UserId == x));
            }
            var memberList = new MembersListViewModel()
            {
                User    = Users,
                HouseId = house.Id
            };

            return(View(memberList));
        }
        public void Can_Paginate()
        {
            //Arrange
            Mock <IMemberRepository> mock = new Mock <IMemberRepository>();

            mock.Setup(m => m.Members).Returns((new Member[]
            {
                new Member {
                    MemberId = "1", MemberName = "M1"
                },
                new Member {
                    MemberId = "2", MemberName = "M2"
                },
                new Member {
                    MemberId = "3", MemberName = "M3"
                },
                new Member {
                    MemberId = "4", MemberName = "M4"
                },
                new Member {
                    MemberId = "5", MemberName = "M5"
                }
            }).AsQueryable <Member>());

            MemberController controller = new MemberController(mock.Object);

            controller.PageSize = 3;

            //Act
            MembersListViewModel result = controller.List(null, 2).ViewData.Model as MembersListViewModel;

            //Assert
            Member[] membArray = result.Members.ToArray();
            Assert.True(membArray.Length == 2);
            Assert.Equal(membArray[0].MemberName, "M4");
            Assert.Equal(membArray[1].MemberName, "M5");
        }
Ejemplo n.º 6
0
        //public MembersList(TransactionTypes transactionType, ItemDTO itemDto)
        //{
        //    InitializeComponent();
        //    Messenger.Default.Send<TransactionTypes>(transactionType);
        //    Messenger.Default.Send<ItemDTO>(itemDto);
        //    Messenger.Reset();
        //}

        private void MembersList_OnClosing(object sender, CancelEventArgs e)
        {
            MembersListViewModel.CleanUp();
        }