Пример #1
0
        //
        // GET: /InformationBrokerConsole/Labor/


        public ActionResult Index(int id = 1)
        {
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = " 1=1 ";

            //--数据权限----------------------------------------------------------------------
            string informationBrokerGuid = BusinessUserBLL.CurrentUser.EnterpriseKey;

            if (string.IsNullOrWhiteSpace(informationBrokerGuid))
            {
                whereClause += " AND 1=2 ";
            }
            else
            {
                whereClause += string.Format(" AND [InformationBrokerUserGuid]= '{0}' ", informationBrokerGuid);
            }
            //--end--------------------------------------------------------------------------


            string orderClause = "LaborID DESC";

            PagedEntityCollection <LaborEntity> entityList  = LaborBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <LaborEntity>             pagedExList = new PagedList <LaborEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
        /// <summary>
        /// Create a <see cref="MockEntitySet"/> with cities loaded into it.  Load those cities
        /// into the <paramref name="pagedCollection"/>.
        /// </summary>
        /// <param name="raiseCollectionChangedEvents">Whether or not the <see cref="MockEntitySet"/> should raise
        /// <see cref="INotifyCollectionChanged.CollectionChanged"/> events.</param>
        /// <param name="pagedCollection">The <see cref="PagedEntityCollection"/> to hook up to
        /// the loaded <see cref="MockEntitySet"/>.  If <c>null</c>, it will be instantiated.
        /// The cities loaded into the <see cref="MockEntitySet"/> will also be loaded into
        /// the <paramref name="pagedCollection"/>.</param>
        /// <returns>The <see cref="MockEntitySet"/> with cities loaded into it.</returns>
        private MockEntitySet LoadCities(bool raiseCollectionChangedEvents, PagedEntityCollection pagedCollection)
        {
            // Get a mock entity set of cities
            MockEntitySet cities = new MockEntitySet(raiseCollectionChangedEvents);

            // Load a couple of cities into the set
            cities.Add(new City
            {
                Name       = "First City",
                StateName  = "ST",
                CountyName = "County"
            });

            cities.Add(new City
            {
                Name       = "Second City",
                StateName  = "ST",
                CountyName = "County"
            });

            // Create a paged collection for the entity set
            pagedCollection.BackingEntitySet = cities;

            // Process the cities as loaded entities
            pagedCollection.BeginLoad();
            foreach (City city in cities)
            {
                pagedCollection.AddLoadedEntity(city);
            }
            pagedCollection.CompleteLoad();

            return(cities);
        }
        public ActionResult Index(int id = 1)
        {
            //1.如果是点击查询控件的查询按钮,那么将查询条件作为QueryString附加在地址后面(为了在客户端保存查询条件的状体),重新发起一次请求。
            if (this.Request.HttpMethod.ToLower().Contains("post"))
            {
                string targetUrlWithoutParam = Url.Action("Index", new { id = 1 });
                string targetUrl             = QueryControlHelper.GetNewQueryUrl("QueryControl", targetUrlWithoutParam);
                return(Redirect(targetUrl));
            }

            //2.通常情形下走get查询
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = " 1=1 ";

            ////--数据权限----------------------------------------------------------------------
            //whereClause += " AND ( ";
            //whereClause += string.Format(" {0} ", PermissionDataHelper.GetFilterCondition("FinanceUserGuid"));
            //whereClause += string.Format(" OR {0} ", PermissionDataHelper.GetFilterCondition("ProviderUserGuid"));
            //whereClause += string.Format(" OR {0} ", PermissionDataHelper.GetFilterCondition("RecommendUserGuid"));
            //whereClause += string.Format(" OR {0} ", PermissionDataHelper.GetFilterCondition("ServiceUserGuid"));
            //whereClause += " ) ";
            ////--end--------------------------------------------------------------------------

            string orderClause = "InformationBrokerID DESC";

            whereClause += " AND " + QueryControlHelper.GetQueryCondition("QueryControl");

            PagedEntityCollection <InformationBrokerEntity> entityList  = InformationBrokerBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <InformationBrokerEntity>             pagedExList = new PagedList <InformationBrokerEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
Пример #4
0
        /// <summary>
        /// 内部员工列表
        /// </summary>
        /// <returns></returns>
        public ActionResult Index(int id = 1)
        {
            //1.如果是点击查询控件的查询按钮,那么将查询条件作为QueryString附加在地址后面(为了在客户端保存查询条件的状体),重新发起一次请求。
            if (this.Request.HttpMethod.ToLower().Contains("post"))
            {
                string targetUrlWithoutParam = Url.Action("Index", new { id = 1 });
                string targetUrl             = QueryControlHelper.GetNewQueryUrl("QueryControl", targetUrlWithoutParam);
                return(Redirect(targetUrl));
            }

            //2.通常情形下走get查询
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = " 1=1 ";
            string orderClause = "EmployeeID DESC";

            whereClause += " AND " + QueryControlHelper.GetQueryCondition("QueryControl");

            //如果未设置人员的状态,那么仅仅显示当前有效的用户
            if (whereClause.ToLower().Contains("userstatus") == false)
            {
                whereClause += string.Format(" AND UserStatus={0} ", (int)UserStatuses.Normal);
            }

            PagedEntityCollection <EmployeeEntity> entityList  = EmployeeBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <EmployeeEntity>             pagedExList = new PagedList <EmployeeEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
        public void ResetAddsTrackedAddedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(true, pagedCollection);

            // Remove one entity that won't get resurrected
            Entity toRemove = pagedCollection[1];

            cities.Remove(toRemove);

            // And remove another entity that will get resurrected
            Entity toRemoveAndAdd = pagedCollection[0];

            cities.Remove(toRemoveAndAdd);

            // Turn off the events so that the Add isn't raised
            cities.RaiseCollectionChangedEvents = false;
            cities.Add(toRemoveAndAdd);

            // Raise the Reset event to pick up the city that was added back
            cities.ResetCollection();
            Assert.AreEqual <int>(cities.Count, pagedCollection.Count, "pagedCollection.Count should equal the cities count after adding the city back and resetting the collection");
            Assert.IsTrue(pagedCollection.Contains(toRemoveAndAdd), "The city should be back in the pagedCollection after adding it back and resetting the collection");
            Assert.IsFalse(pagedCollection.Contains(toRemove), "The city that was removed but not added back should not be in the pagedCollection");
        }
        public void ResetEventRetainsEntitiesStillInSet()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(false, pagedCollection);

            cities.ResetCollection();
            Assert.AreEqual<int>(cities.Count, pagedCollection.Count, "pagedCollection.Count should match cities.Count after resetting the collection");
        }
        public void ResetEventRetainsEntitiesStillInSet()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(false, pagedCollection);

            cities.ResetCollection();
            Assert.AreEqual <int>(cities.Count, pagedCollection.Count, "pagedCollection.Count should match cities.Count after resetting the collection");
        }
        public void ResetRemovesClearedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(true, pagedCollection);

            // This will clear the set and raise a Reset event
            // This particular scenario is what led to the bug reported
            cities.Clear();
            Assert.AreEqual <int>(0, pagedCollection.Count, "pagedCollection.Count should be 0 after clearing the cities set");
        }
        public void ResetRemovesClearedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(true, pagedCollection);

            // This will clear the set and raise a Reset event
            // This particular scenario is what led to the bug reported
            cities.Clear();
            Assert.AreEqual<int>(0, pagedCollection.Count, "pagedCollection.Count should be 0 after clearing the cities set");
        }
Пример #10
0
        public ActionResult NewsCategoryList(int id = 1)
        {
            int    pageIndex   = id;
            int    pageSize    = ConfigConst.CountPerPageForManage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = "";
            string orderClause = "";
            PagedEntityCollection <NewsCategoryEntity> coll      = NewsCategoryBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <NewsCategoryEntity>             pagedList = new PagedList <NewsCategoryEntity>(coll.Records, coll.PageIndex, coll.PageSize, coll.TotalCount);

            return(View(pagedList));
        }
Пример #11
0
        /// <summary>
        /// 劳务人员薪资列表
        /// </summary>
        /// <returns></returns>
        public ActionResult SalaryList(int id = 1)
        {
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = " 1=1 ";
            string orderClause = "SalarySummaryID DESC";

            whereClause += string.Format(" AND LaborKey='{0}' ", BusinessUserBLL.CurrentUserGuid);
            PagedEntityCollection <SalarySummaryEntity> entityList  = SalarySummaryBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <SalarySummaryEntity>             pagedExList = new PagedList <SalarySummaryEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
        public void ResetRemovesRemovedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(false, pagedCollection);

            Entity toRemove = pagedCollection[0];

            cities.Remove(toRemove);
            Assert.AreEqual<int>(cities.Count + 1, pagedCollection.Count, "pagedCollection.Count should be one more than cities.Count after removing the city from the cities set");
            Assert.IsTrue(pagedCollection.Contains(toRemove), "pagedCollection should still contain the city removed from the cities set until the Reset is raised");

            cities.ResetCollection();
            Assert.AreEqual<int>(cities.Count, pagedCollection.Count, "pagedCollection.Count should match cities.Count after resetting the collection");
            Assert.IsFalse(pagedCollection.Contains(toRemove), "pagedCollection should no longer contain the city removed from the cities set after resetting the collection");
        }
        public void ResetRemovesRemovedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(false, pagedCollection);

            Entity toRemove = pagedCollection[0];

            cities.Remove(toRemove);
            Assert.AreEqual <int>(cities.Count + 1, pagedCollection.Count, "pagedCollection.Count should be one more than cities.Count after removing the city from the cities set");
            Assert.IsTrue(pagedCollection.Contains(toRemove), "pagedCollection should still contain the city removed from the cities set until the Reset is raised");

            cities.ResetCollection();
            Assert.AreEqual <int>(cities.Count, pagedCollection.Count, "pagedCollection.Count should match cities.Count after resetting the collection");
            Assert.IsFalse(pagedCollection.Contains(toRemove), "pagedCollection should no longer contain the city removed from the cities set after resetting the collection");
        }
        public void RepeatedEntitiesNoDuplicated()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });

            // This will load the cities into the collection the first time
            MockEntitySet cities = LoadCities(false, pagedCollection);

            // Now we'll load the cities into the collection a second time
            pagedCollection.BeginLoad();
            foreach (City city in cities)
            {
                pagedCollection.AddLoadedEntity(city);
            }
            pagedCollection.CompleteLoad();

            Assert.AreEqual(cities.Count, pagedCollection.Count, "The counts should still match");
        }
Пример #15
0
        //
        // GET: /EnterpriseConsole/Labor/

        public ActionResult Index(int id = 1)
        {
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = " 1=1 ";

            //--数据权限----------------------------------------------------------------------
            whereClause += string.Format(" AND [CurrentEnterpriseKey]= '{0}' AND LaborWorkStatus={1} ", BusinessUserBLL.CurrentUser.EnterpriseKey, (int)LaborWorkStatuses.Worked);
            //--end--------------------------------------------------------------------------


            string orderClause = "LaborID DESC";

            PagedEntityCollection <LaborEntity> entityList  = LaborBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <LaborEntity>             pagedExList = new PagedList <LaborEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
        public void ResetIgnoresUntrackedAddedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(false, pagedCollection);

            City toAdd = new City
            {
                Name = "New City",
                StateName = "ST",
                CountyName = "County"
            };

            cities.Add(toAdd);
            Assert.AreEqual<int>(cities.Count - 1, pagedCollection.Count, "pagedCollection.Count should be one less than cities.Count after adding the city to the cities set");
            Assert.IsFalse(pagedCollection.Contains(toAdd), "pagedCollection should not contain the city added to the cities set before the Reset is raised");

            cities.ResetCollection();
            Assert.AreEqual<int>(cities.Count - 1, pagedCollection.Count, "pagedCollection.Count should be one less than cities.Count after resetting the collection");
            Assert.IsFalse(pagedCollection.Contains(toAdd), "pagedCollection should not contain the city added to the cities set after resetting the collection");
        }
        public void ResetIgnoresUntrackedAddedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(false, pagedCollection);

            City toAdd = new City
            {
                Name       = "New City",
                StateName  = "ST",
                CountyName = "County"
            };

            cities.Add(toAdd);
            Assert.AreEqual <int>(cities.Count - 1, pagedCollection.Count, "pagedCollection.Count should be one less than cities.Count after adding the city to the cities set");
            Assert.IsFalse(pagedCollection.Contains(toAdd), "pagedCollection should not contain the city added to the cities set before the Reset is raised");

            cities.ResetCollection();
            Assert.AreEqual <int>(cities.Count - 1, pagedCollection.Count, "pagedCollection.Count should be one less than cities.Count after resetting the collection");
            Assert.IsFalse(pagedCollection.Contains(toAdd), "pagedCollection should not contain the city added to the cities set after resetting the collection");
        }
        public void AddEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name       = "Added City",
                StateName  = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType <City>().First();

            cities.Remove(removedCity);

            // A new city should not be added to the collection
            City addedCity = new City
            {
                Name       = "Added City 2",
                StateName  = "ST",
                CountyName = "County"
            };

            this.AssertCollectionChanged(
                () => cities.Add(addedCity),
                pagedCollection,
                (NotifyCollectionChangedEventArgs)null,
                "when adding a new city.");

            // A restored city should be re-added to the collection
            this.AssertCollectionChanged(
                () => cities.Add(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, removedCity, pagedCollection.Count - 1),
                "when re-adding a removed city.");
        }
Пример #19
0
        /// <summary>
        /// 新闻列表
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public ActionResult Index(int id = 1, string code = StringHelper.Empty)
        {
            int pageIndex  = id;
            int pageSize   = ConfigConst.CountPerPageForEndUser;
            int startIndex = (pageIndex - 1) * pageSize + 1;

            string whereClause = string.Format(" CanUsable={0} ", (int)Logics.True);

            if (string.IsNullOrWhiteSpace(code) == false)
            {
                whereClause += string.Format("  AND NewsCategoryCode like '{0}%'", code);
            }

            string orderClause = "NewsID DESC";

            PagedEntityCollection <NewsEntity> coll      = NewsBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <NewsEntity>             pagedList = new PagedList <NewsEntity>(coll.Records, coll.PageIndex, coll.PageSize, coll.TotalCount);

            this.ViewBag.CategoryCode = code;
            return(View(pagedList));
        }
        public void ResetEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(false, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name       = "Added City",
                StateName  = "ST",
                CountyName = "County"
            });

            this.AssertCollectionChanged(
                () => cities.ResetCollection(),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset),
                "when resetting the collection.");
        }
Пример #21
0
        public ActionResult Index(int id = 1)
        {
            //1.如果是点击查询控件的查询按钮,那么将查询条件作为QueryString附加在地址后面(为了在客户端保存查询条件的状体),重新发起一次请求。
            if (this.Request.HttpMethod.ToLower().Contains("post"))
            {
                string targetUrlWithoutParam = Url.Action("Index", new { id = 1 });
                string targetUrl             = QueryControlHelper.GetNewQueryUrl("QueryControl", targetUrlWithoutParam);
                return(Redirect(targetUrl));
            }

            //2.通常情形下走get查询
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = string.Format(" 1=1  AND ReceiverKey='{0}' ", BusinessUserBLL.CurrentUser.UserGuid); //string.Format(" LoanType= {0} AND LoanStatus!={1}  ",                (int)loanType, (int)LoanStatuses.UserUnCompleted);
            string orderClause = "RemindID DESC";

            whereClause += " AND " + QueryControlHelper.GetQueryCondition("QueryControl");

            PagedEntityCollection <RemindEntity> entityList  = RemindBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <RemindEntity>             pagedExList = new PagedList <RemindEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
        public void RemoveEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return(true); });
            MockEntitySet         cities          = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name       = "Added City",
                StateName  = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType <City>().First();

            this.AssertCollectionChanged(
                () => cities.Remove(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedCity, 0),
                "when removing a city.");
        }
Пример #23
0
        public ActionResult OperateLogList(int id = 1)
        {
            //1.如果是点击查询控件的查询按钮,那么将查询条件作为QueryString附加在地址后面(为了在客户端保存查询条件的状体),重新发起一次请求。
            if (this.Request.HttpMethod.ToLower().Contains("post"))
            {
                string targetUrlWithoutParam = Url.Action("OperateLogList", new { id = 1 });
                string targetUrl             = QueryControlHelper.GetNewQueryUrl("QueryControl", targetUrlWithoutParam);
                return(Redirect(targetUrl));
            }

            //2.通常情形下走get查询
            int    pageIndex   = id;
            int    pageSize    = SystemConst.CountPerPage;
            int    startIndex  = (pageIndex - 1) * pageSize + 1;
            string whereClause = " 1=1 ";
            string orderClause = "LogID DESC";

            whereClause += " AND " + QueryControlHelper.GetQueryCondition("QueryControl");

            PagedEntityCollection <OperateLogEntity> entityList  = OperateLogBLL.Instance.GetPagedCollection(startIndex, pageSize, whereClause, orderClause);
            PagedList <OperateLogEntity>             pagedExList = new PagedList <OperateLogEntity>(entityList.Records, entityList.PageIndex, entityList.PageSize, entityList.TotalCount);

            return(View(pagedExList));
        }
        public void ResetAddsTrackedAddedEntities()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(true, pagedCollection);

            // Remove one entity that won't get resurrected
            Entity toRemove = pagedCollection[1];
            cities.Remove(toRemove);

            // And remove another entity that will get resurrected
            Entity toRemoveAndAdd = pagedCollection[0];
            cities.Remove(toRemoveAndAdd);

            // Turn off the events so that the Add isn't raised
            cities.RaiseCollectionChangedEvents = false;
            cities.Add(toRemoveAndAdd);

            // Raise the Reset event to pick up the city that was added back
            cities.ResetCollection();
            Assert.AreEqual<int>(cities.Count, pagedCollection.Count, "pagedCollection.Count should equal the cities count after adding the city back and resetting the collection");
            Assert.IsTrue(pagedCollection.Contains(toRemoveAndAdd), "The city should be back in the pagedCollection after adding it back and resetting the collection");
            Assert.IsFalse(pagedCollection.Contains(toRemove), "The city that was removed but not added back should not be in the pagedCollection");
        }
        public void ResetEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(false, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
                {
                    Name = "Added City",
                    StateName = "ST",
                    CountyName = "County"
                });

            this.AssertCollectionChanged(
                () => cities.ResetCollection(),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset),
                "when resetting the collection.");
        }
        public void RemoveEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name = "Added City",
                StateName = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType<City>().First();
            this.AssertCollectionChanged(
                () => cities.Remove(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, removedCity, 0),
                "when removing a city.");
        }
        public void AddEventRelayed()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });
            MockEntitySet cities = LoadCities(true, pagedCollection);

            // Remove an item
            pagedCollection.RemoveAt(0);

            // Add an item
            pagedCollection.Add(new City
            {
                Name = "Added City",
                StateName = "ST",
                CountyName = "County"
            });

            City removedCity = pagedCollection.OfType<City>().First();
            cities.Remove(removedCity);

            // A new city should not be added to the collection
            City addedCity = new City
            {
                Name = "Added City 2",
                StateName = "ST",
                CountyName = "County"
            };

            this.AssertCollectionChanged(
                () => cities.Add(addedCity),
                pagedCollection,
                (NotifyCollectionChangedEventArgs)null,
                "when adding a new city.");

            // A restored city should be re-added to the collection
            this.AssertCollectionChanged(
                () => cities.Add(removedCity),
                pagedCollection,
                new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, removedCity, pagedCollection.Count - 1),
                "when re-adding a removed city.");
        }
        /// <summary>
        /// Create a <see cref="MockEntitySet"/> with cities loaded into it.  Load those cities
        /// into the <paramref name="pagedCollection"/>.
        /// </summary>
        /// <param name="raiseCollectionChangedEvents">Whether or not the <see cref="MockEntitySet"/> should raise
        /// <see cref="INotifyCollectionChanged.CollectionChanged"/> events.</param>
        /// <param name="pagedCollection">The <see cref="PagedEntityCollection"/> to hook up to
        /// the loaded <see cref="MockEntitySet"/>.  If <c>null</c>, it will be instantiated.
        /// The cities loaded into the <see cref="MockEntitySet"/> will also be loaded into
        /// the <paramref name="pagedCollection"/>.</param>
        /// <returns>The <see cref="MockEntitySet"/> with cities loaded into it.</returns>
        private MockEntitySet LoadCities(bool raiseCollectionChangedEvents, PagedEntityCollection pagedCollection)
        {
            // Get a mock entity set of cities
            MockEntitySet cities = new MockEntitySet(raiseCollectionChangedEvents);

            // Load a couple of cities into the set
            cities.Add(new City
            {
                Name = "First City",
                StateName = "ST",
                CountyName = "County"
            });

            cities.Add(new City
            {
                Name = "Second City",
                StateName = "ST",
                CountyName = "County"
            });

            // Create a paged collection for the entity set
            pagedCollection.BackingEntitySet = cities;

            // Process the cities as loaded entities
            pagedCollection.BeginLoad();
            foreach (City city in cities)
            {
                pagedCollection.AddLoadedEntity(city);
            }
            pagedCollection.CompleteLoad();

            return cities;
        }
        public void RepeatedEntitiesNoDuplicated()
        {
            PagedEntityCollection pagedCollection = new PagedEntityCollection(p => { return true; });

            // This will load the cities into the collection the first time
            MockEntitySet cities = LoadCities(false, pagedCollection);

            // Now we'll load the cities into the collection a second time
            pagedCollection.BeginLoad();
            foreach (City city in cities)
            {
                pagedCollection.AddLoadedEntity(city);
            }
            pagedCollection.CompleteLoad();

            Assert.AreEqual(cities.Count, pagedCollection.Count, "The counts should still match");
        }