public ActionResult DeleteConfirmed(int id) { Book book = MappingWeb.ConvertToWebEntity(_bookRepo.Read(id)); _bookRepo.Delete(MappingWeb.ConvertToBusinessEntity(book)); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Owner owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(id)); _ownerRepo.Delete(MappingWeb.ConvertToBusinessEntity(owner)); return(RedirectToAction("Index")); }
public ActionResult DeleteConfirmed(int id) { Author author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(id)); _authorRepo.Delete(MappingWeb.ConvertToBusinessEntity(author)); return(RedirectToAction("Index")); }
// GET: Owners public ActionResult Index() { var owners = _ownerRepo.ReadAll(); var list = new List <Owner>(); foreach (var owner in owners) { list.Add(MappingWeb.ConvertToWebEntity(owner)); } return(View(list)); }
// GET: Authors public ActionResult Index() { var authors = _authorRepo.ReadAll(); var list = new List <Author>(); foreach (var author in authors) { list.Add(MappingWeb.ConvertToWebEntity(author)); } return(View(list)); }
// GET: Owners/Edit/5 public ActionResult Edit(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Owner owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(id)); if (owner == null) { return(HttpNotFound()); } return(View(owner)); }
// GET: Authors/Details/5 public ActionResult Details(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Author author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(id)); if (author == null) { return(HttpNotFound()); } return(View(author)); }
public ActionResult Hire(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Book book = MappingWeb.ConvertToWebEntity(_bookRepo.Read(id)); if (book == null) { return(HttpNotFound()); } //ViewBag.AuthorId = new SelectList(_authorRepo.ReadAll(), "Id", "Name", book.AuthorId); ViewBag.OwnerId = new SelectList(_ownerRepo.ReadAll(), "Id", "Name", book.OwnerId); return(View(book)); }
public ActionResult Edit([Bind(Include = "Id,Name,ISBN,countPages,datePublished,AuthorId")] Book book) { if (ModelState.IsValid) { book.Author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(book.AuthorId)); var ownerIdFromRepo = MappingWeb.ConvertToWebEntity(_bookRepo.Read(book.Id)).OwnerId; book.isDeleted = false; book.OwnerId = ownerIdFromRepo; book.Owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(ownerIdFromRepo)); _bookRepo.Update(MappingWeb.ConvertToBusinessEntity(book)); return(RedirectToAction("Index")); } ViewBag.AuthorId = new SelectList(_authorRepo.ReadAll(), "Id", "Name", book.AuthorId); ViewBag.OwnerId = new SelectList(_ownerRepo.ReadAll(), "Id", "Name", book.OwnerId); return(View(book)); }
// GET: Books/Details/5 public ActionResult Details(int id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Book book = MappingWeb.ConvertToWebEntity(_bookRepo.Read(id)); book.Author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(book.AuthorId)); book.Owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(book.OwnerId)); if (book == null) { return(HttpNotFound()); } return(View(book)); }
// GET: Books public ActionResult Index() { var books = _bookRepo.ReadAll(); var list = new List <Book>(); foreach (var book in books) { //book.Author = _authorRepo.Read(book.AuthorId); //book.Owner = _ownerRepo.Read(book.OwnerId); var current = MappingWeb.ConvertToWebEntity(book); current.Author = MappingWeb.ConvertToWebEntity(_authorRepo.Read(book.AuthorId)); current.Owner = MappingWeb.ConvertToWebEntity(_ownerRepo.Read(book.OwnerId)); list.Add(current); } return(View(list)); }