コード例 #1
0
ファイル: Edit.xaml.cs プロジェクト: 2Andrey2/Coursework
        private void EditButton_Click(object sender, RoutedEventArgs e)
        {
            string[] temp = { };
            if (MainBookTable.Visibility == Visibility.Visible)
            {
                CollectionBook item = MainBookTable.SelectedItem as CollectionBook;
                string[]       mass = { "Книги", item.Автор, item.Название, item.Жанр, item.Издатель, item.Материал, item.асположение, Convert.ToString(item.Цена) };
                temp = mass;
            }
            if (MainMagazineTable.Visibility == Visibility.Visible)
            {
                CollectionMagazine item = MainMagazineTable.SelectedItem as CollectionMagazine;
                string[]           mass = { "Журнал", item.Название, item.Автор, item.Тема, item.асположение, item.Жанр, item.Издатель, item.Аудитория, Convert.ToString(item.Цена) };
                temp = mass;
            }
            if (MainСhancelleryTable.Visibility == Visibility.Visible)
            {
                CollectionChancellery item = MainСhancelleryTable.SelectedItem as CollectionChancellery;
                string[] mass = { "Концелярия", item.Название, item.асположение, item.Производитель, item.Категория, Convert.ToString(item.Цена) };
                temp = mass;
            }
            IProductsManagement product = new ProductsManagement();

            temp = temp.Where(x => x != "").ToArray();
            product.ProductAction("Delete", temp);
            product.ProductAction("Created", workingtable.data_collection(TypeProduct, massBookObject, massMagazineObject, massСhancelleryObject));
        }
コード例 #2
0
        public void AsFlattenedEnumerable_AllowsEnumeratingAllPagesAsSingleEnumeration()
        {
            var pages = new Collection<IPagedCollection<string>>();
            IPagedCollection<string> pageZero = new PagedCollection<string> { MaxItems = 8 };
            pageZero.Add("zero");
            pageZero.Add("one");
            pageZero.Add("two");

            pages.Add(pageZero);
            IPagedCollection<string> pageOne = new PagedCollection<string> { MaxItems = 8 };
            pageOne.Add("three");
            pageOne.Add("four");
            pageOne.Add("five");
            pages.Add(pageOne);

            IPagedCollection<string> pageTwo = new PagedCollection<string> { MaxItems = 8 };
            pageTwo.Add("six");
            pageTwo.Add("seven");
            pages.Add(pageTwo);

            var book = new CollectionBook<string>((pageIndex, pageSize) => pages[pageIndex], 3);

            // act
            string concatenation = String.Join("", book.AsFlattenedEnumerable().ToArray());

            // assert
            Assert.AreEqual("zeroonetwothreefourfivesixseven", concatenation);
        }
コード例 #3
0
        public IActionResult AddBook(JsonElement Data)
        {
            string CollectionId = Data.GetProperty("collectionId").GetString();
            string BookId       = Data.GetProperty("bookId").GetString();

            //Collection CollectionToAppend = db.Collections.Find(CollectionId);
            //Book BookToAdd = db.Books.Find(BookId);

            CollectionBook NewCollectionBook = new CollectionBook
            {
                CollectionId = CollectionId,
                BookId       = BookId
            };

            //CollectionToAppend.CollectionBooks.Add(NewCollectionBook);
            //db.SaveChanges();
            //BookToAdd.CollectionBooks.Add(NewCollectionBook);
            //db.SaveChanges();

            //Console.WriteLine(CollectionToAppend.CollectionBooks.Count);

            //db.Collections.Remove(CollectionToAppend);
            //db.Collections.Add(CollectionToAppend);
            //db.Books.Remove(BookToAdd);
            //db.Books.Add(BookToAdd);
            db.CollectionBooks.Add(NewCollectionBook);
            db.SaveChanges();

            return(Json(new
            {
                success = true
            }));
        }
コード例 #4
0
 public ActionResult Read(int ID)
 {
     try
     {
         return(View(CollectionBook.GetReadBookModel(ID)));
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return(View("Error"));
     }
 }
コード例 #5
0
ファイル: IndexingService.cs プロジェクト: ghjigan/Subtext
        private IEnumerable <SearchEngineEntry> GetBlogPosts()
        {
            const int pageSize       = 100;
            var       collectionBook = new CollectionBook <EntryStatsView>((pageIndex, sizeOfPage) => Repository.GetEntries(PostType.BlogPost, null, pageIndex, sizeOfPage), pageSize);

            foreach (var entry in collectionBook.AsFlattenedEnumerable())
            {
                if (entry.IsActive)
                {
                    yield return(entry.ConvertToSearchEngineEntry());
                }
            }
        }
コード例 #6
0
 public ActionResult Details(int id)
 {
     try
     {
         int userID = (int)Profile["ID"];
         var model  = CollectionBook.GetCollectionBookPageModel(id, userID);
         return(View(model));
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return(View("Error"));
     }
 }
コード例 #7
0
        public IEnumerable <BlogMLPost> GetBlogPosts(bool embedAttachments)
        {
            const int pageSize       = 100;
            var       collectionBook = new CollectionBook <EntryStatsView>((pageIndex, sizeOfPage) => SubtextContext.Repository.GetEntriesForExport(pageIndex, sizeOfPage), pageSize);

            foreach (var entry in collectionBook.AsFlattenedEnumerable())
            {
                var post = BlogMLConverter.ConvertEntry(entry, embedAttachments);
                foreach (var categoryTitle in entry.Categories)
                {
                    post.Categories.Add(CategoryByTitleLookup[categoryTitle].ID.ToString(CultureInfo.InvariantCulture));
                }
                yield return(post);
            }
        }
コード例 #8
0
        public void CollectionBook_WithThreePages_IteratesCorrectly()
        {
            var pages = new Collection <IPagedCollection <string> >();
            IPagedCollection <string> pageZero = new PagedCollection <string> {
                MaxItems = 8
            };

            pageZero.Add("zero");
            pageZero.Add("one");
            pageZero.Add("two");
            pages.Add(pageZero);

            IPagedCollection <string> pageOne = new PagedCollection <string> {
                MaxItems = 8
            };

            pageOne.Add("three");
            pageOne.Add("four");
            pageOne.Add("five");
            pages.Add(pageOne);

            IPagedCollection <string> pageTwo = new PagedCollection <string> {
                MaxItems = 8
            };

            pageTwo.Add("six");
            pageTwo.Add("seven");
            pages.Add(pageTwo);

            var book = new CollectionBook <string>((pageIndex, pageSize) => pages[pageIndex], 3);

            string concatenation    = string.Empty;
            int    currentPageIndex = 0;

            // act
            foreach (var page in book)
            {
                concatenation += currentPageIndex;
                foreach (string item in page)
                {
                    concatenation += item;
                }
                currentPageIndex++;
            }

            // assert
            Assert.AreEqual("0zeroonetwo1threefourfive2sixseven", concatenation);
        }
コード例 #9
0
        public IActionResult RemoveBook(JsonElement Data)
        {
            string CollectionId = Data.GetProperty("collectionId").GetString();
            string BookId       = Data.GetProperty("bookId").GetString();

            CollectionBook CollectionBookToRemove = db.CollectionBooks
                                                    .FirstOrDefault(cb => cb.CollectionId == CollectionId && cb.BookId == BookId);

            db.CollectionBooks.Remove(CollectionBookToRemove);
            db.SaveChanges();

            return(Json(new
            {
                success = true
            }));
        }
コード例 #10
0
ファイル: CollectionBookTests.cs プロジェクト: ayende/Subtext
        public void CanIteratePagedCollectionsInABook()
        {
            Collection<IPagedCollection<string>> pages = new Collection<IPagedCollection<string>>();
            IPagedCollection<string> pageZero = new PagedCollection<string>();
            pageZero.MaxItems = 8;
            pageZero.Add("zero");
            pageZero.Add("one");
            pageZero.Add("two");

            pages.Add(pageZero);
            IPagedCollection<string> pageOne = new PagedCollection<string>();
            pageOne.MaxItems = 8;
            pageOne.Add("three");
            pageOne.Add("four");
            pageOne.Add("five");
            pages.Add(pageOne);

            IPagedCollection<string> pageTwo = new PagedCollection<string>();
            pageTwo.MaxItems = 8;
            pageTwo.Add("six");
            pageTwo.Add("seven");
            pages.Add(pageTwo);

            CollectionBook<string> book = new CollectionBook<string>(
                delegate(int pageIndex, int pageSize)
                {
                    return pages[pageIndex];
                }, 3);

            string concatenation = string.Empty;
            int currentPageIndex = 0;
            foreach(IPagedCollection<string> page in book)
            {
                concatenation += currentPageIndex;
                foreach(string item in page)
                {
                    concatenation += item;
                }
                currentPageIndex++;
            }
            Assert.AreEqual("0zeroonetwo1threefourfive2sixseven", concatenation, "We iterated correctly.");
        }
コード例 #11
0
        public void CollectionBook_WithThreePages_IteratesCorrectly()
        {
            var pages = new Collection<IPagedCollection<string>>();
            IPagedCollection<string> pageZero = new PagedCollection<string> {MaxItems = 8};
            pageZero.Add("zero");
            pageZero.Add("one");
            pageZero.Add("two");
            pages.Add(pageZero);

            IPagedCollection<string> pageOne = new PagedCollection<string> {MaxItems = 8};
            pageOne.Add("three");
            pageOne.Add("four");
            pageOne.Add("five");
            pages.Add(pageOne);

            IPagedCollection<string> pageTwo = new PagedCollection<string> {MaxItems = 8};
            pageTwo.Add("six");
            pageTwo.Add("seven");
            pages.Add(pageTwo);

            var book = new CollectionBook<string>((pageIndex, pageSize) => pages[pageIndex], 3);

            string concatenation = string.Empty;
            int currentPageIndex = 0;

            // act
            foreach(var page in book)
            {
                concatenation += currentPageIndex;
                foreach(string item in page)
                {
                    concatenation += item;
                }
                currentPageIndex++;
            }

            // assert
            Assert.AreEqual("0zeroonetwo1threefourfive2sixseven", concatenation);
        }
コード例 #12
0
        private void MainMagazineTable_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid data = (DataGrid)sender;

            if (data.SelectedIndex != -1)
            {
                itemBook        = null;
                itemMagazine    = null;
                itemChancellery = null;
                if (data.Name == "MainBookTable")
                {
                    itemBook = data.SelectedItem as CollectionBook;
                }
                if (data.Name == "MainMagazineTable")
                {
                    itemMagazine = data.SelectedItem as CollectionMagazine;
                }
                if (data.Name == "MainСhancelleryTable")
                {
                    itemChancellery = data.SelectedItem as CollectionChancellery;
                }
            }
        }
コード例 #13
0
 public ActionResult Delete(int ID, string returnUrl)
 {
     try
     {
         var clBook = manager.collectionService.GetCollectionBookById(ID);
         manager.collectionService.RemoveBook(clBook);
         if (Request.IsAjaxRequest())
         {
             return(PartialView("_CollectionsBookManageView", CollectionBook.GetBookInCollectionModel(clBook.BookID,
                                                                                                      (int)Profile["ID"])));
         }
         if (Url.IsLocalUrl(returnUrl))
         {
             return(Redirect(returnUrl));
         }
         return(RedirectToAction("Index", "Collection"));
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return(View("Error"));
     }
 }
コード例 #14
0
ファイル: Edit.xaml.cs プロジェクト: 2Andrey2/Coursework
        private void MainBookTable_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            DataGrid data = (DataGrid)sender;

            if (data.SelectedIndex != -1)
            {
                if (data.Name == "MainBookTable")
                {
                    CollectionBook item = data.SelectedItem as CollectionBook;
                    NameBookT.Text = item.Название; AuthorBookT.Text = item.Автор; GenreBookT.Text = item.Жанр; ManufacturerBookT.Text = item.Издатель; MaterialBookT.Text = item.Материал; StorageBookT.Text = item.асположение; PriceBookT.Text = Convert.ToString(item.Цена);
                }
                if (data.Name == "MainMagazineTable")
                {
                    CollectionMagazine item = data.SelectedItem as CollectionMagazine;
                    NameMagazineT.Text = item.Название; AuthorMagazineT.Text = item.Автор; TopicMagazineT.Text = item.Тема; StorageMagazineT.Text = item.асположение; GenreMagazineT.Text = item.Жанр; ManufacturerMagazineT.Text = item.Издатель; AudienceMagazineT.Text = item.Аудитория; PriceMagazineT.Text = Convert.ToString(item.Цена);
                }
                if (data.Name == "MainСhancelleryTable")
                {
                    CollectionChancellery item = data.SelectedItem as CollectionChancellery;
                    NameСhancelleryT.Text = item.Название; StorageСhancelleryT.Text = item.асположение; ManufacturerСhancelleryT.Text = item.Производитель; AppointmentСhancelleryT.Text = item.Категория; PriceСhancelleryT.Text = Convert.ToString(item.Цена);
                }
            }
        }
コード例 #15
0
        public void AsFlattenedEnumerable_AllowsEnumeratingAllPagesAsSingleEnumeration()
        {
            var pages = new Collection <IPagedCollection <string> >();
            IPagedCollection <string> pageZero = new PagedCollection <string> {
                MaxItems = 8
            };

            pageZero.Add("zero");
            pageZero.Add("one");
            pageZero.Add("two");

            pages.Add(pageZero);
            IPagedCollection <string> pageOne = new PagedCollection <string> {
                MaxItems = 8
            };

            pageOne.Add("three");
            pageOne.Add("four");
            pageOne.Add("five");
            pages.Add(pageOne);

            IPagedCollection <string> pageTwo = new PagedCollection <string> {
                MaxItems = 8
            };

            pageTwo.Add("six");
            pageTwo.Add("seven");
            pages.Add(pageTwo);

            var book = new CollectionBook <string>((pageIndex, pageSize) => pages[pageIndex], 3);

            // act
            string concatenation = String.Join("", book.AsFlattenedEnumerable().ToArray());

            // assert
            Assert.AreEqual("zeroonetwothreefourfivesixseven", concatenation);
        }
コード例 #16
0
 public ActionResult Add(int bookID, int clID, string returnUrl)
 {
     try
     {
         var dbBook = manager.bookService.GetBookById(bookID);
         var dbCl   = manager.collectionService.GetCollectionById(clID);
         manager.collectionService.AddBook(dbCl, dbBook);
         if (Request.IsAjaxRequest())
         {
             return(PartialView("_CollectionsBookManageView", CollectionBook.GetBookInCollectionModel(bookID,
                                                                                                      (int)Profile["ID"])));
         }
         if (Url.IsLocalUrl(returnUrl))
         {
             return(Redirect(returnUrl));
         }
         return(RedirectToAction("Index", "Collection"));
     }
     catch (Exception ex)
     {
         logger.Error(ex);
         return(View("Error"));
     }
 }
コード例 #17
0
ファイル: BlogMLSource.cs プロジェクト: ChrisPelatari/SubText
 public IEnumerable<BlogMLPost> GetBlogPosts(bool embedAttachments)
 {
     const int pageSize = 100;
     var collectionBook = new CollectionBook<EntryStatsView>((pageIndex, sizeOfPage) => SubtextContext.Repository.GetEntriesForExport(pageIndex, sizeOfPage), pageSize);
     foreach(var entry in collectionBook.AsFlattenedEnumerable())
     {
         var post = BlogMLConverter.ConvertEntry(entry, embedAttachments);
         foreach(var categoryTitle in entry.Categories)
         {
             post.Categories.Add(CategoryByTitleLookup[categoryTitle].ID.ToString(CultureInfo.InvariantCulture));
         }
         yield return post;
     }
 }
コード例 #18
0
 private IEnumerable<SearchEngineEntry> GetBlogPosts()
 {
     const int pageSize = 100;
     var collectionBook = new CollectionBook<EntryStatsView>((pageIndex, sizeOfPage) => Repository.GetEntries(PostType.BlogPost, null, pageIndex, sizeOfPage), pageSize);
     foreach (var entry in collectionBook.AsFlattenedEnumerable())
     {
         if (entry.IsActive)
             yield return entry.ConvertToSearchEngineEntry();
     }
 }
コード例 #19
0
ファイル: BlogMlWriter.cs プロジェクト: ayende/Subtext
        /// <summary>
        /// Writes the blog.
        /// </summary>
        protected override void InternalWriteBlog()
        {
            bmlBlog = this.provider.GetBlog(this.blogId);

            WriteStartBlog(bmlBlog.Title, ContentTypes.Text, bmlBlog.SubTitle, ContentTypes.Text, bmlBlog.RootUrl, bmlBlog.DateCreated);
            WriteAuthors();
            WriteExtendedProperties();

            IList<BlogMLCategory> categories = provider.GetAllCategories(this.blogId);
            WriteCategories(categories);

            ICollectionBook<BlogMLPost> allPosts = new CollectionBook<BlogMLPost>
                (
                    delegate(int pageIndex, int pageSize)
                    {
                        return provider.GetBlogPosts(this.blogId, pageIndex, pageSize);
                    }, provider.PageSize
                );
            WritePosts(allPosts);

            WriteEndElement(); // End Blog Element
            Writer.Flush();
        }