public async Task <IActionResult> Edit(int id, [Bind("NovelId,NovelName,NovelPrice,NovelAuthor")] Novels novels) { if (id != novels.NovelId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(novels); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!NovelsExists(novels.NovelId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(novels)); }
public async Task <IActionResult> Create([Bind("NovelId,NovelName,NovelPrice,NovelAuthor")] Novels novels) { if (ModelState.IsValid) { _context.Add(novels); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(novels)); }
public IActionResult Get(int id) { try { Novels novels = _repository.GetOne(id); return(Ok(novels)); } catch (Exception ex) { return(StatusCode(StatusCodes.Status500InternalServerError)); } }
protected override void InitComponents() { var tr = FindWidget <Transform>("expBg"); expSlider = new WExpSlider(); expSlider.SetGameObj(tr.gameObject); btnReturn = FindWidget <Button>("btnReturn"); btnReturn.onClick.AddListener(() => { OnUnloadThis(); LoadAnotherUI <UIMain>(); }); textNovel = FindWidget <Text>("textNovel"); textNovel.text = GetCurPage(); btnLeft = FindWidget <Button>("btnLeft"); btnLeft.gameObject.SetActive(iCurPage > 0); btnLeft.onClick.AddListener(() => { var c = Novels.GetContent(iCurSection, iCurPage - 1); if (c == null) { UIAlert.Show("已到达本章第一页。"); btnLeft.gameObject.SetActive(true); return; } textNovel.text = c; iCurPage--; btnRight.gameObject.SetActive(true); }); btnRight = FindWidget <Button>("btnRight"); btnRight.gameObject.SetActive(!Novels.IsLastPage(iCurSection, iCurPage)); btnRight.onClick.AddListener(() => { var c = Novels.GetContent(iCurSection, iCurPage + 1); if (c == null) { UIAlert.Show("已到达本章最后一页。"); btnRight.gameObject.SetActive(false); return; } textNovel.text = c; iCurPage++; btnLeft.gameObject.SetActive(true); }); }
public static Global.Novels ToGobal(this Novels n) { return(new Global.Novels() { Id = n.Id, Title = n.Title, Serie = n.Serie, SerieId = n.SerieId, Authors = n.Authors, SerialNumber = n.SerialNumber, Price = n.Price, Informations = n.Informations, Langue = n.Langue, Dimension = n.Dimension, Published = n.Published, Type = n.Type, TypeId = n.TypeId }); }
private string GetCurPage() { return(Novels.GetContent(iCurSection, iCurPage)); }
public void Update(int id, Novels n) { _globalNovels.Update(id, n.ToGobal()); }
public void Add(Novels n) { _globalNovels.Add(n.ToGobal()); }
// Scaffold-DbContext "Server=.;Database=BooksDB2019;Trusted_Connection=True;" // Microsoft.EntityFrameworkCore.SqlServer -OutputDir Domain static void Main(string[] args) { Console.WriteLine("Select an option:"); Console.WriteLine("1) Authors"); Console.WriteLine("2) Novels"); Console.WriteLine("3) Authors And Novels"); Console.WriteLine("4) All"); int result = int.Parse(Console.ReadLine()); using (UnitOfWork uow = new UnitOfWork()) { try { if (result == 1) { List <Authors> authors = uow.AuthorsRepository.GetAll(); Console.WriteLine("Authors:"); foreach (var author in authors) { Console.WriteLine($"{author.Id}) {author.Name} Born: {author.DateOfBirth}"); } } else if (result == 2) { List <Novels> novels = uow.NovelsRepository.GetAll(); Console.WriteLine("Novels:"); foreach (var novel in novels) { Console.WriteLine($"{novel.Id}) {novel.Title} Is Read: {novel.IsRead}"); } } else if (result == 3) { List <Authors> authors = uow.AuthorsRepository.GetAll(); List <Novels> novels = uow.NovelsRepository.GetAll(); Console.WriteLine("Authors:"); foreach (var author in authors) { Console.WriteLine($"{author.Id}) {author.Name} Born: {author.DateOfBirth}"); } Console.WriteLine("-------------------------------------------------"); Console.WriteLine("Novels:"); foreach (var novel in novels) { Console.WriteLine($"{novel.Id}) {novel.Title} Is Read: {novel.IsRead}"); } } else { List <Authors> all = uow.AuthorsRepository.GetAllWithMembers(); Console.WriteLine("Everything"); foreach (var author in all) { Console.WriteLine($"{author.Id}) {author.Name} Born: {author.DateOfBirth}, Books: {author.Novels.Count}"); Novels firstBook = author.Novels != null && author.Novels.Count != 0 ? author.Novels.First() : null; if (firstBook == null) { Console.WriteLine("No books!"); } else { string award = firstBook.Nominations != null && firstBook.Nominations.Count != 0 ? firstBook.Nominations.First().Award.AwardName : "No nominations"; Console.WriteLine($" First Book: {firstBook.Title}, Nomination: {award}"); } } } uow.Commit(); // Here we save all changes to the database ( In this example there are no changes in the database ) } catch (Exception ex) { uow.Reject(); Console.WriteLine(ex.Message); } Console.ReadLine(); } }
static void Main(string[] args) { Library thousandBooks = new Library("Thousand Books"); Novels ulysses = new Novels("James Joyce", "Ulysses", EditionType.Hardcover, 345, false); Novels theGreatGatsby = new Novels("F. Scott Fitzgerald", "The Great Gatsby", EditionType.EBook, 2222, false); Novels lolita = new Novels("Vladimir Nabokov", "Lolita", EditionType.AudioBook, 422, false); Novels catch22 = new Novels("Joseph Heller", "Catch 22", EditionType.Paperback, 356, false); Novels harryPoter = new Novels(" J. K. Rowling", "Harry Potter", EditionType.Hardcover, 4522, false); Novels harryPotterandtheHalfBloodPrince = new Novels("J.K. Rowling", "Harry Potter and the Half-Blood Prince", EditionType.Hardcover, 642, true); Novels harryPotterandTheGobletOfFire = new Novels("J.K. Rowling", "Harry Potter and the Goblet of Fire", EditionType.Hardcover, 922, true); Novels harryPoterAndTheChamberOfSeacret = new Novels("J.K. Rowling", "Harry Potter And The Chamber Of Seacret", EditionType.Hardcover, 399, true); harryPoter.AddToSeries(harryPoterAndTheChamberOfSeacret); harryPoter.AddToSeries(harryPotterandTheGobletOfFire); harryPoter.AddToSeries(harryPotterandtheHalfBloodPrince); StoryCollection sticks = new StoryCollection("Unknown", "Sticks", StoryType.ShortStory, true); StoryCollection victoryLap = new StoryCollection("Unknown", "Victory Lap", StoryType.Novellete, true); StoryCollections tenthOfDecember = new StoryCollections("George Saunders", "Tenth of December", EditionType.Paperback, 1244); tenthOfDecember.AddStory(sticks); tenthOfDecember.AddStory(victoryLap); Anthology fragileThings = new Anthology("Neil Gaiman", "fantastic", EditionType.Hardcover, 360, "Fragile Things"); StoryAnthology closingTime = new StoryAnthology("Closing Time", "Robert Aickman", StoryType.ShortStory, true); StoryAnthology aLoveStory = new StoryAnthology("A Love Story", "Waren Pleece", StoryType.ShortStory, true); fragileThings.AddStory(closingTime); fragileThings.AddStory(aLoveStory); thousandBooks.AddBook(harryPoter); thousandBooks.AddBook(tenthOfDecember); thousandBooks.AddBook(fragileThings); var allBooks = thousandBooks.GetBooks(); //------------------------------------------------------------------------------------ string input = Console.ReadLine(); if (input == "novela") { PrintNovela(allBooks); } Console.WriteLine("\n----------------"); if (input == "coll") { PrintCollectionStory(allBooks); } Console.WriteLine("\n----------------"); if (input == "ant") { PrintAnthology(allBooks); } Console.WriteLine("\n----------------"); //------------------------------------------------------------------------------------ // Print PrintCollectionStory(allBooks); Console.WriteLine("\n----------------"); Console.WriteLine("Anthology : \n"); PrintAnthology(allBooks); Console.WriteLine("\n----------------"); Console.WriteLine("Novelas : \n"); PrintNovela(allBooks); Console.WriteLine("\n----------------"); Console.ReadLine(); }
/// <summary> /// 新增 /// </summary> /// <param name="t">实体</param> /// <returns>返回受影响行数</returns> public int Add(Novels t) { var result = iNovels_DAL.Add(t); return(result); }
/// <summary> /// 修改 /// </summary> /// <param name="t">实体</param> /// <returns>返回受影响行数</returns> public int Update(Novels t) { var result = iNovels_DAL.Update(t); return(result); }