public IActionResult EditeBook(int?id, eBook lct) { if (id == null) { //return StatusCode(StatusCodes.Status400BadRequest); ViewData["field"] = "eBook"; return(View("NullError")); } var ebook = context_.eBooks.Find(id); if (ebook != null) { ebook.Title = lct.Title; ebook.Author = lct.Author; try { context_.SaveChanges(); } catch (Exception) { // do nothing for now ViewData["field"] = "eBook"; return(View("NullError")); } } else { ViewData["field"] = "eBook"; return(View("NullError")); } return(RedirectToAction("eBooks")); }
public ActionResult PublisherDetails(int?id) { if (id == null) { //return StatusCode(StatusCodes.Status400BadRequest); ViewData["field"] = "Publisher"; return(View("NullError")); } Publisher publisher = context_.Publishers.Find(id); if (publisher == null) { //return StatusCode(StatusCodes.Status404NotFound); ViewData["field"] = "Publisher"; return(View("NullError")); } var ebooks = context_.eBooks.Where(l => l.Publishers == publisher); publisher.eBooks = ebooks.OrderBy(l => l.Title).Select(l => l).ToList <eBook>(); if (publisher.eBooks == null) { publisher.eBooks = new List <eBook>(); eBook lct = new eBook(); lct.Title = "none"; lct.Author = "none"; publisher.eBooks.Add(lct); } return(View(publisher)); }
private static Displayable MapToEBook(ElasticTitleIndex elasticProduct, Displayable displayable) { var eBookItem = new eBook { HasAttachment = elasticProduct.HasAttachment }; Book book = (Book)eBookItem; displayable = MapBookToDisplayable(elasticProduct, book); return(displayable); }
private void AddeBook(string theCall, string theTitle, string theName, string theGenre, int thePages, string thePublisher, double theSize) { theEBook = new eBook(theCall,theTitle, theName, theGenre, thePages, thePublisher, theSize); theEBook.CallNumber = theCall; theEBook.BookTitle = theTitle; theEBook.AuthorName = theName; theEBook.Genre = theGenre; theEBook.NumberOfPages = thePages; theEBook.Publisher = thePublisher; theEBook.Filesize = theSize; listOfBooks.Add(theEBook); }
public IActionResult EditeBook(int?id) { if (id == null) { //return StatusCode(Microsoft.AspNetCore.Http.StatusCodes.Status400BadRequest); ViewData["field"] = "eBook"; return(View("NullError")); } eBook ebook = context_.eBooks.Find(id); if (ebook == null) { //return StatusCode(StatusCodes.Status404NotFound); ViewData["field"] = "eBook"; return(View("NullError")); } return(View(ebook)); }
public IActionResult AddeBook(int id) { HttpContext.Session.SetInt32(sessionId_, id); //if (id == null) Publisher publisher = context_.Publishers.Find(id); if (publisher == null) { // return StatusCode(StatusCodes.Status404NotFound); ViewData["field"] = "Publisher"; return(View("NullError")); } eBook lct = new eBook(); return(View(lct)); }
public IActionResult AddeBook(int?id, eBook lct) { if (id == null) { // return StatusCode(StatusCodes.Status400BadRequest); ViewData["field"] = "Publisher"; return(View("NullError")); } int?publisherId_ = HttpContext.Session.GetInt32(sessionId_); var publisher = context_.Publishers.Find(publisherId_); if (publisher != null) { if (publisher.eBooks == null) { List <eBook> ebooks = new List <eBook>(); publisher.eBooks = ebooks; } try { IFormFile file = Request.Form.Files["MYeBook"]; if (Request.Form.Files["MYeBook"] == null) { //Console.WriteLine("File not uploaded!!!!!!!!!!!!"); string field = "eBook"; return(RedirectToAction("Error", "Home", new { field = field })); } var path = "/FileStorage/" + file.FileName; //var path2 = "/FileStorageAdmin/" + file.FileName; lct.Name = file.FileName; lct.Path = path; lct.UserName = User.Identity.Name; //var path = ""; //if (User.IsInRole("Admin")) //{ // lct.Path = path2; // path = Path.Combine(ebookPathAdmin, file.FileName); //} //else //{ // lct.Path = path1; // path = Path.Combine(ebookPath, file.FileName); //} var path1 = Path.Combine(ebookPath, file.FileName); FileInfo file1 = new FileInfo(path1); //Console.WriteLine(path); if (file1.Exists) { return(RedirectToAction("FileExist")); } MultipartFormDataContent multiContent = new MultipartFormDataContent(); byte[] data; using (var br = new BinaryReader(file.OpenReadStream())) data = br.ReadBytes((int)file.OpenReadStream().Length); ByteArrayContent bytes = new ByteArrayContent(data); multiContent.Add(bytes, "file", file.FileName); var result = client.PostAsync(baseUrl_, multiContent).Result; if ((int)result.StatusCode == 200) { if (ModelState.IsValid) { publisher.eBooks.Add(lct); context_.SaveChanges(); //return RedirectToAction("eBooks"); } else { return(NotFound()); } } else { return(NotFound()); } //else //{ // string field = "eBook"; // return RedirectToAction("Error", "Home", new { field = field }); //} } catch (Exception) { // do nothing for now ViewData["data"] = "eBook"; return(View("UploadError")); } } else { ViewData["field"] = "Publisher"; return(View("NullError")); } return(RedirectToAction("eBooks")); }
public IActionResult CreateeBook(int id, eBook ebook) { context_.eBooks.Add(ebook); context_.SaveChanges(); return(RedirectToAction("eBooks")); }
public IActionResult CreateeBook(int id) { var model = new eBook(); return(View(model)); }