public blogPost parse() { blogPost blogPost = new blogPost(); //quitamos la ruta string title = fileRoute.Split('\\')[fileRoute.Split('\\').Length - 1]; //Obtener extension del archivo switch (this.fileRoute.Split('.')[this.fileRoute.Split('.').Length - 1]) { case "txt": this.reducer = new TextReducer(); blogPost.title = title.Replace(".txt", ""); blogPost.body = this.reducer.reduceContent(this.fileRoute); break; case "pdf": blogPost.title = title.Replace(".pdf", ""); this.reducer = new PDFReducer(); blogPost.body = this.reducer.reduceContent(this.fileRoute); break; case "html": blogPost.title = title.Replace(".html", ""); this.reducer = new HTMLParser(); blogPost.body = this.reducer.reduceContent(this.fileRoute); break; } return(blogPost); }
public void Delete(blogPost postToDelete) { // do we want to search for the id? var identifiedPost = GetById(postToDelete.Id); _postList.Remove(identifiedPost); }
public void Edit(blogPost editedPost) { // var identifiedPostToUpdate = _postList.GetById(editedPost.Id); // Find(d => d.Id == editedPost.Id); var identifiedPostToUpdate = GetById(editedPost.Id); identifiedPostToUpdate.AuthorLname = editedPost.AuthorLname; identifiedPostToUpdate.AuthorFname = editedPost.AuthorFname; identifiedPostToUpdate.Date = editedPost.Date; identifiedPostToUpdate.content = editedPost.content; }
public IActionResult Delete(blogPost postToDelete, int id, IFormCollection collection) { try { // TODO: Add delete logic here _postRepo.Delete(postToDelete); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public IActionResult Edit(blogPost editedPost, int id, IFormCollection collection) { try { if (ModelState.IsValid) { _postRepo.Edit(editedPost); return(RedirectToAction(nameof(Index))); } return(View(editedPost)); } catch { return(View(editedPost)); } }
public IActionResult Create(blogPost newBlog, IFormCollection collection) { try { if (ModelState.IsValid) { _postRepo.Add(newBlog); return(RedirectToAction(nameof(Index))); } return(View(newBlog)); } catch { return(View(newBlog)); } }
public IActionResult About() { ViewData["Message"] = "Your application description page."; var myPost = new blogPost { AuthorFname = "Bill", AuthorLname = "Chandler", Date = "29Jan2018", content = "some blog post somewhere at some time signifying something of scintillating substance" }; _postRepo.Add(myPost); return(View(myPost)); return(View()); }
public void Add(blogPost newPost) { newPost.Id = NextId++; _postList.Add(newPost); }