Beispiel #1
0
 public void EditBook(Book book)
 {
     throw new NotImplementedException();
 }
Beispiel #2
0
        public virtual ActionResult AddPost(AddPostModel postModel)
        {
            if (!ModelState.IsValid)
                return PartialView(MVC.Admin.Shared.Views._ValidationSummery);

            postModel.PostBody = postModel.PostBody.ToSafeHtml();
            postModel.Book.Description = postModel.Book.Description.ToSafeHtml();

            var post = new Post
            {
                Body = postModel.PostBody,
                CommentStatus = postModel.PostCommentStatus,
                CreatedDate = DateAndTime.GetDateTime(),
                Description = postModel.PostDescription,
                Keyword = postModel.PostKeyword,
                Status = postModel.PostStatus.ToString().ToLower(),
                Title = postModel.PostTitle
            };

            var book = new Book
            {
                Author = postModel.Book.Author,
                Description = postModel.Book.Description,
                ISBN = postModel.Book.ISBN,
                Language = postModel.Book.Language,
                Name = postModel.Book.Name,
                Year = postModel.Book.Year,
                Publisher = postModel.Book.Publisher,
                Page = postModel.Book.Page
            };

            var bookImage = new BookImage
            {
                Path = postModel.BookImage.Path,
                Title = postModel.BookImage.Title,
                Description = postModel.BookImage.Description,
                UploadedDate = DateAndTime.GetDateTime()
            };

            var links = new List<DownloadLink>();

            if (!string.IsNullOrEmpty(postModel.DownloadLinks.DownloadLink1.Link))
            {
                links.Add(postModel.DownloadLinks.DownloadLink1);
            }
            if (!string.IsNullOrEmpty(postModel.DownloadLinks.DownloadLink2.Link))
            {
                links.Add(postModel.DownloadLinks.DownloadLink2);
            }
            if (!string.IsNullOrEmpty(postModel.DownloadLinks.DownloadLink3.Link))
            {
                links.Add(postModel.DownloadLinks.DownloadLink3);
            }
            if (!string.IsNullOrEmpty(postModel.DownloadLinks.DownloadLink4.Link))
            {
                links.Add(postModel.DownloadLinks.DownloadLink4);
            }

            post.Book = book;
            post.DownloadLinks = links;
            post.Book.Image = bookImage;
            post.User = _userService.GetUserByUserName(User.Identity.Name);
            post.Labels = _labelService.GetLabelsById(postModel.LabelId);

            _postService.AddPost(post);
            _uow.SaveChanges();

            #region Indexing new book by Lucene.NET

            //Index the new book lucene.NET
            Post lastPost = _postService.Find(post.Id);
            LuceneBookSearch.AddUpdateLuceneIndex(new LuceneBookModel
            {
                Author = lastPost.Book.Author,
                Description = HtmlUtility.RemoveHtmlTags(lastPost.Book.Description),
                ISBN = lastPost.Book.ISBN,
                Name = lastPost.Book.Name,
                PostId = lastPost.Id,
                Publisher = lastPost.Book.Publisher,
                Title = lastPost.Title
            });

            #endregion

            return PartialView(MVC.Admin.Shared.Views._Alert,
                new Alert { Message = "پست جدید با موقیت در سیستم ثبت شد", Mode = AlertMode.Success });
        }
Beispiel #3
0
 public void AddBook(Book book)
 {
     _books.Add(book);
 }