Ejemplo n.º 1
0
 public void TwoDPagesWithUnmatchedKeys_ArentEquivilant()
 {
     DPage first = new DPage { key = 1 };
     DPage second = new DPage { key = 2 };
     bool equivilant = first.Equivilant(second);
     Assert.IsFalse(equivilant);
 }
Ejemplo n.º 2
0
 public void DPageAndBPageWithMatchingKeys_AreNotEquivilant()
 {
     DPage first = new DPage { key = 1 };
     BPage second = new BPage { Page_ID = 2 };
     bool equivilant = first.Equivilant(second);
     Assert.IsFalse(equivilant);
 }
Ejemplo n.º 3
0
 public void TwoDPagesWithMatchingKeys_AreEquivilant()
 {
     int key = -1;
     DPage first = new DPage { key = key };
     DPage second = new DPage { key = key };
     bool equivilant = first.Equivilant(second);
     Assert.IsTrue(equivilant);
 }
        public IEnumerable<IEnumerable<DPage>> PageStructure_GetBySelected(int Page_ID)
        {
            List<IEnumerable<DPage>> pageStructure = new List<IEnumerable<DPage>>();
            IEnumerable<DPage> children;
            DPage i;

            DPage starting = Page_FromID(Page_ID);
            if(starting == null){
                return pageStructure;
            }

            if ((children = SqlSPageRepository.Children(starting)).Count() > 0) {
                pageStructure.Insert(0, children);
            }

            IEnumerable<DPage> currentRow = SqlSPageRepository.Siblings(starting);
            currentRow.First(x => x.Page_ID == Page_ID).inFocus = true;
            pageStructure.Insert(0, currentRow);

            //Starting from back up, parent rows are added.
            i = new DPage{Page_ID = starting.Parent_Page_ID};
            int currentPageID;
            while(true){
                IEnumerable<DPage> nextRow = SqlSPageRepository.Siblings(i);
                currentPageID = i.Page_ID;

                if(i.Page_ID == 0 || (i = nextRow.FirstOrDefault()) == null){
                    break;                  //Top of tree has been reached, no more parents.
                }
                nextRow.First(x => x.Page_ID == currentPageID).inFocus = true;

                pageStructure.Insert(0, nextRow);

                i.Page_ID = i.Parent_Page_ID;
            }
            return pageStructure;
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            Repository.Configuration.connString = "Server=localhost;Database=ApplicationData;Trusted_Connection=True;";
            IInfastructureService service = new InfastructureService();
            DPage Home = new DPage{
                Url = "http://www.jonathan-burrows.com",
                Name = "Home",
                Title = "Main page of JonathanBurrows.com"
            };
            DPage Applications = new DPage {
                Url = "http://www.jonathan-burrows.com/projects",
                Name = "Projects",
                Title = "Newest projects/documentation",
                Parent_Page_ID = 6
            };
            DPage Mailit = new DPage {
                Url = "http://www.jonathan-burrows.com/mailit",
                Name = "Mailit",
                Title = "Email Application",
                Parent_Page_ID = 7
            };
            DPage MailitApplication = new DPage {
                Url = "http://www.jonathan-burrows.com/mailit-application",
                Name = "Application",
                Title = "Use the application",
                Parent_Page_ID = 9
            };
            DPage MailitHome = new DPage{
                Url = "~/",
                Name = "Mailit Home",
                Title = "Portal page of Mailit",
                Parent_Page_ID = 21
            };
            DPage Create = new DPage{
                Url = "~/create",
                Name = "Create",
                Title = "Create a new message",
                Parent_Page_ID = 21
            };
            DPage Inbox = new DPage{
                Url = "~/inbox",
                Name = "Inbox",
                Title = "View all received messages",
                Parent_Page_ID = 21
            };
            DPage Sent = new DPage{
                Url = "~/sent",
                Name = "Sent",
                Title = "View all sent messages",
                Parent_Page_ID = 21
            };
            DPage Friends = new DPage{
                Url = "~/friends",
                Name = "Friends",
                Title = "Manage friends/blocked users.",
                Parent_Page_ID = 21
            };

            service.Page_Create(MailitApplication);

            //service.Page_Create(MailitHome);
            //service.Page_Create(Create);
            //service.Page_Create(Inbox);
            //service.Page_Create(Sent);
            //service.Page_Create(Friends);

            //DPage page = service.Page_FromUrl("Url2");
            //IEnumerable<IEnumerable<DPage>> pages = service.PageStructure_GetBySelected(page.Url);
            //Console.WriteLine(pages.Count());
        }
Ejemplo n.º 6
0
 public void DPage_IsEquivilantToItself()
 {
     DPage page = new DPage { key = -1};
     bool equivilant = page.Equivilant(page);
     Assert.IsTrue(equivilant);
 }
 public DPage Page_Update(DPage updating)
 {
     IDataRepository<DPage> pages = SqlSPageRepository.ByID(updating.Page_ID);
     pages.Update(updating);
     return updating;
 }
 public void Page_Delete(DPage deleting)
 {
     IDataRepository<DPage> pages = SqlSPageRepository.ByID(deleting.Page_ID);
     pages.Delete(deleting);
 }
 public DPage Page_Create(DPage creating)
 {
     IDataRepository<DPage> pages = RepositoryFactory.Instance.Construct<DPage>();
     pages.Create(creating);
     return creating;
 }