public void Post([FromBody] Bookshelf bookshelf) { if (ModelState.IsValid) { _bookshelfService.Create(bookshelf); } }
void Buy() { if (status == Status.Buy || status == Status.Finish || status == Status.Destroy) { return; } Bookshelf target_bookshelf = null; foreach (var bookshelf in ManageMaster.Instance.BookshelfManager.Bookshelves) { if (bookshelf.Obj.GetInstanceID() == instance_id) { target_bookshelf = bookshelf; if (target_bookshelf.Produt == null) { status = Status.Buy; return; } break; } } target_bookshelf.Quantity--; if (target_bookshelf.Button.gameObject.GetInstanceID() == StaticDatas.Instance.TargetBookshelf.Button.gameObject.GetInstanceID()) { ManageMaster.Instance.ProductManager.ProductQuanity.text = target_bookshelf.Quantity.ToString(); } if (target_bookshelf.Produt == null) { status = Status.Buy; return; } buy_produtlist.Add(target_bookshelf.Produt.SimplePrice); status = Status.Buy; }
public async Task <IActionResult> AddBook( [Bind("ISBN,Name,FetchBookNumber,BarCode,BookshelfId,State")] Book book) { if (ModelState.IsValid) { BookDetails bookDetails = this.LendingInfoDbContext.BookDetail.FirstOrDefault(b => b.ISBN == book.ISBN); Book existBook = this.LendingInfoDbContext.Books.AsNoTracking() .FirstOrDefault(b => b.BarCode == book.BarCode); if (existBook != null) { TempData["message"] = $"已有二维码为{book.BarCode}的书籍《{existBook.Name}》的借阅信息"; return(this.RedirectToAction("AddBook", new { isbn = book.ISBN })); } if (bookDetails.Name == book.Name) { Bookshelf bookshelf = this.LendingInfoDbContext.Bookshelves.Include(b => b.Books) .FirstOrDefault(b => b.BookshelfId == book.BookshelfId); if (bookshelf != null) { book.Sort = bookshelf.Sort; book.Location = bookshelf.Location; bookshelf.Books.Add(book); bookshelf.MaxFetchNumber = bookshelf.Books.Max(b => b.FetchBookNumber); bookshelf.MinFetchNumber = bookshelf.Books.Min(b => b.FetchBookNumber); } await this.LendingInfoDbContext.Books.AddAsync(book); await this.LendingInfoDbContext.SaveChangesAsync(); TempData["message"] = $"《{book.Name}》{book.BarCode}的借阅信息添加成功"; return(this.RedirectToAction("Books", new { isbn = book.ISBN })); } } return(this.View(book)); }
public bool DeleteBookshelf(int id) { Bookshelf shelfToDelete = _context.Bookshelves.Single(b => b.BookshelfId == id); _context.Bookshelves.Remove(shelfToDelete); return(_context.SaveChanges() == 1); }
public async Task <IActionResult> EditBook(string oldBarCode, [Bind("BarCode,BookshelfId,Name,State")] Book book) { if (ModelState.IsValid) { Book oldBook = _lendingInfoDbContext.Books.FirstOrDefault(b => b.BarCode == oldBarCode); if (oldBook == null) { TempData["message"] = $"不存在二维码为{oldBarCode}的书籍"; return(RedirectToAction("BookDetails")); } if (oldBook.Name == book.Name) { book.ISBN = oldBook.ISBN; book.FetchBookNumber = oldBook.FetchBookNumber; Bookshelf bookshelf = _lendingInfoDbContext.Bookshelves.Include(b => b.Books).FirstOrDefault(b => b.BookshelfId == book.BookshelfId); if (bookshelf != null) { book.Sort = bookshelf.Sort; book.Location = bookshelf.Location; bookshelf.Books.Remove(oldBook); bookshelf.Books.Add(book); } _lendingInfoDbContext.Books.Remove(oldBook); _lendingInfoDbContext.Books.Add(book); await _lendingInfoDbContext.SaveChangesAsync(); TempData["message"] = "修改成功"; return(RedirectToAction("Books", new { isbn = oldBook.ISBN })); } } return(View(book)); }
public async override Task ExecuteAsync(CommandContext context) { EnterMessage = Localizer["AddBookshelfEnter"]; NoExitstMessage = Localizer["AddBookshelfSuccess"]; ExistMessage = Localizer["AddBookshelfError"]; IReplyMarkup keyboard = new ReplyKeyboardRemove(); if (InputData(context, out Bookshelf bookshelf)) { if (bookshelf == null) { bookshelf = new Bookshelf { Name = context.Parameters ?? context.Data, User = context.User }; context.AddBookshelf(bookshelf); context.CommandName = null; keyboard = CommandKeyboards.GetMainMenu(Localizer); } else { context.CommandName = Name; } } await BotClient.SendTextMessageAsync(context.Message.Chat, Message, replyMarkup : keyboard); }
public async Task <Bookshelf> AddBookToBookshelfAsync(Book book) { var bookItem = _context.Books.Where(item => item.Id == book.Id).FirstOrDefault(); if (bookItem == null) { _context.Authors.AddRange(book.Authors); _context.Categories.AddRange(book.Categories); _context.Books.Add(book); await _context.SaveChangesAsync(); bookItem = book; } if (!_context.Bookshelves.Any()) { var bookshelf = new Bookshelf() { Books = new List <Book>() }; bookshelf.Books.Add(bookItem); _context.Bookshelves.Add(bookshelf); } else { var bookshelf = _context.Bookshelves.Include(bookshelf => bookshelf.Books).ToList(); bookshelf.FirstOrDefault() .Books.Add(bookItem); } await _context.SaveChangesAsync(); return(_context.Bookshelves.FirstOrDefault()); }
public override bool Test(Sim a, Bookshelf target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool found = false; List <IGameObject> topStackItems = target.Inventory.GetTopStackItems(); foreach (IGameObject obj in topStackItems) { Book book = obj as Book; if (book == null) { continue; } if ((book is BookGeneral) || (book is BookWritten)) { ReadBookData data; if (a.ReadBookDataList.TryGetValue(book.Data.ID, out data)) { if (data.TimesRead == 0) { found = true; break; } } else { found = true; break; } } } return(found); }
public IEnumerable <Bookshelf> GetByPerson(int personId) { try { string selectString = "select pb.PersonId, pb.BookId, b.Title, b.Author, b.CoverPhoto " + "from PERSONBOOK as pb " + "inner join BOOK as b " + "on pb.BookId = b.BookId " + "where pb.PersonId = @personId"; using (SqlConnection conn = new SqlConnection(connectionString)) { conn.Open(); using (SqlCommand command = new SqlCommand(selectString, conn)) { command.Parameters.AddWithValue("@personId", personId); using (SqlDataReader reader = command.ExecuteReader()) { List <Bookshelf> result = new List <Bookshelf>(); while (reader.Read()) { Bookshelf item = ReadBookshelf(reader); result.Add(item); } return(result); } } } } catch (Exception) { //future handling exceptions return(null); } }
public IActionResult Create([FromBody] Bookshelf bookshelf) { _context.Bookshelf.Add(bookshelf); _context.SaveChanges(); return(CreatedAtRoute("GetBookShelf", new { id = bookshelf.Id }, bookshelf)); }
private void InteractWith(Bookshelf bookshelf) { Utility.Execute(booksToTake, bookshelf.ContainBook, book => { BookModel bookModel = bookshelf.books.Find(b => b.book == book); if (bookshelf.TransferBook(this, bookModel)) { booksToTake.Remove(bookModel.book); } else { Debug.Log( $"Could not transfer book '{book.Title}' to player because already transporting max book count"); } }); Utility.Execute(booksToStore, bookshelf.ShouldStoreBookIn, b => { if (!TransferBook(bookshelf, b)) { Debug.Log( $"Could not transfer book '{b.book.Title}' to {bookshelf.name} because already containing max book count"); } booksToStore.Remove(b); }); }
public IActionResult MyBookshelf() { if (HttpContext.Session.GetObjectFromJson <User>("newUser") == null) { return(Redirect("/")); } var bookWithInfo = (from book in _context.Books join bookinfo in _context.Book_info on book.ISBN equals bookinfo.ISBN select new { Id = book.Id, OwnerId = book.OwnerId, Author = book.Author, Title = book.Title, ISBN = book.ISBN, Available = book.Available, ImageUrl = bookinfo.ImageUrl, Description = bookinfo.Description, LinkToGoogleBooks = bookinfo.LinkToGoogleBooks }).ToList(); List <BookWithInfo> booksWithInfo = new List <BookWithInfo>(); foreach (var book in bookWithInfo) { booksWithInfo.Add(new BookWithInfo(book.Id, book.OwnerId, book.Author, book.Title, book.ISBN, book.Available, book.ImageUrl, book.Description, book.LinkToGoogleBooks)); } long UserId = HttpContext.Session.GetObjectFromJson <User>("newUser").Id; Bookshelf newBookshelf = new Bookshelf(UserId, _context, booksWithInfo); return(View(newBookshelf)); }
public void Put(int id, [FromBody] Bookshelf bookshelf) { if (ModelState.IsValid) { bookshelf.Id = id; _bookshelfService.Update(bookshelf); } }
public static Bookshelf Instantiate(List <Book> assignedBooks, List <BookModel> books, Vector3 position, Quaternion rotation) { Bookshelf bookshelf = Instantiate(GameManager.gm.pm.BookshelfPrefab, position, rotation); bookshelf.assignedBooks = assignedBooks; bookshelf.books = books; return(bookshelf); }
// Start is called before the first frame update void Start() { animator = GetComponent <Animator>(); trashcan = FindObjectOfType <Trashcan>(); fort = FindObjectOfType <Fort>(); bookshelf = FindObjectOfType <Bookshelf>(); // Register this object for pause/unpause updates SceneDirector.GetPrimary().Register(this); }
protected BookBookshelf CreateBookBookshelfData(Book book, Bookshelf bookshelf) { var bookBookshelf = new BookBookshelf() { Book = book, Bookshelf = bookshelf }; this.context.BooksBookshelves.Add(bookBookshelf); this.context.SaveChanges(); return(bookBookshelf); }
protected Bookshelf CreateBookshelfData(HoneypotUser user) { var bookshelf = new Bookshelf() { Title = TestsConstants.Title1, UserId = user.Id, Id = TestsConstants.Id2 }; this.context.Bookshelves.Add(bookshelf); this.context.SaveChanges(); return(bookshelf); }
public async Task <GetBookshelfApiModel> Handle(GetBookshelfQuery request, CancellationToken cancellationToken) { GoogleData.Bookshelf googleBookshelf = await _booksService.Mylibrary.Bookshelves.Get(request.BookshelfId.ToString()).ExecuteAsync(); if (googleBookshelf == null) { return(ApiModel.NotFound <GetBookshelfApiModel>()); } Bookshelf bookshelf = _mapper.Map <Bookshelf>(googleBookshelf); return(new GetBookshelfApiModel(bookshelf)); }
private void Awake() { unit = GetComponent <Unit>(); if (unit != null) { unit.UpdateContents += HandleUpdateEvent; unit.LoadContents += HandleLoadEvent; unit.DoneLoading = false; } Data = new Bookshelf(CallNumber, CallNumber, ShelfCount, ShelfWidth); bookPool = Manager.BookPool; }
public async Task <IActionResult> CreateNewBookshelf([FromBody] NewBookshelfRequest request) { var userId = int.Parse(User.FindFirst(ClaimTypes.NameIdentifier).Value); var user = await _unitOfWork.Users.GetAsync(userId); var bookshelf = new Bookshelf { Description = request.Description, LibraryId = user.LibraryId }; _unitOfWork.Bookshelves.Add(bookshelf); var affected = await _unitOfWork.CommitAsync(); return(affected < 1 ? BadRequest() : Ok()); }
public void JsonSerializerBookshelfTest() { String filePath = "..\\..\\..\\..\\TestResults\\jsonFileBookshelf.json"; JsonSerializer.Serialize(bookshelf, filePath); bookshelfDeserialized = JsonSerializer.Deserialize <Bookshelf>(filePath); Assert.IsNotNull(bookshelfDeserialized); Assert.AreNotSame(bookshelf, bookshelfDeserialized); CollectionAssert.AreEqual(bookshelf.Books, bookshelfDeserialized.Books); CollectionAssert.AreEqual(bookshelf.BookGenres, bookshelfDeserialized.BookGenres); }
private IEnumerator HandleLoadEvent(IUnit unit) { var shelf = unit as Bookshelf; if (shelf == null) { Debug.LogError("BookshelfController: IUnit not Bookshelf on LoadEvent"); yield break; } Data = shelf; yield return(InstantiateTable()); Display.text = Data.Start; }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Bookshelf = await _context.Bookshelf.FirstOrDefaultAsync(m => m.ID == id); if (Bookshelf == null) { return(NotFound()); } return(Page()); }
private IEnumerator HandleUpdateEvent(Unit lastUnit, Direction direction) { unit.DoneLoading = false; // TODO consider letting this be accessed by row controller if (direction == Direction.Null) { Clear(); unit.DoneLoading = true; yield break; } // get references to data var last = lastUnit.GetComponent <BookshelfController>(); if (last == null) { Debug.LogError("Could not get last shelf"); yield break; } var lastData = last.Data; if (lastData == null) { Debug.LogError("Last unit did not have data"); yield break; } // load data var done = false; Data = new Bookshelf(lastData.Start, lastData.End, ShelfCount, ShelfWidth); new Thread(o => { Data.Load(direction); done = true; }).Start(); // instantiate gameObjects while (!done) { yield return(null); } unit.DoneLoading = true; yield return(InstantiateTable()); unit.Row.NotifyScrollOk(); Display.text = Data.Start; }
public bool CreateBookshelf(BookshelfCreate model) { var bookshelfToCreate = new Bookshelf() { UserId = _userId, ShelfName = model.ShelfName, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Bookshelves.Add(bookshelfToCreate); return(ctx.SaveChanges() == 1); } }
public void Ini() { var list = GameObject.Find("BookshelfList").GetComponentsInChildren <Button>(); var index = 0; var list_obj = GameObject.FindGameObjectsWithTag("Bookshelf"); foreach (var data in list) { Bookshelf book = new Bookshelf(); book.Button = data; book.Obj = list_obj[index]; bookshelves.Add(book); index++; } }
public bool PutAwayBook(Common.IStatGenerator stats, Book book, Lot lot) { Bookshelf shelf = book.MyShelf; if ((shelf == null) || (!shelf.InWorld)) { List <Bookshelf> shelves = new List <Bookshelf>(); foreach (Bookshelf choice in lot.GetObjects <Bookshelf>()) { if (choice.Inventory == null) { continue; } if (!choice.InWorld) { continue; } if ((choice.Repairable != null) && (choice.Repairable.Broken)) { continue; } shelves.Add(choice); } if (shelves.Count > 0) { shelf = RandomUtil.GetRandomObjectFromList(shelves); } } if (shelf != null) { stats.IncStat("Book Shelved"); shelf.Inventory.TryToMove(book); return(true); } else { stats.IncStat("No Shelf"); return(false); } }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Bookshelf = await _context.Bookshelf.FindAsync(id); if (Bookshelf != null) { _context.Bookshelf.Remove(Bookshelf); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public bool CreateBookshelf(BookshelfCreate model) { UserProfile profile = _context.UserProfiles.Single(p => p.OwnerId == _userId); List <Book> allBooks = _context.Books.ToList(); Bookshelf shelf = new Bookshelf() { Title = model.Title, OwnerId = _userId, BookIds = model.BookIds, Books = allBooks.Where(b => model.BookIds.Contains(b.BookId)).ToList(), UserProfileId = profile.UserProfileId }; _context.Bookshelves.Add(shelf); return(_context.SaveChanges() > 0); }
private void Awake() { unit = GetComponent <Unit>(); if (unit != null) { unit.UpdateContents += HandleUpdateEvent; unit.LoadContents += HandleLoadEvent; unit.DoneLoading = false; } Data = new Bookshelf(CallNumber, CallNumber, ShelfCount, ShelfWidth); bookPool = Manager.BookPool; for (var i = 0; i < ShelfCount; i++) { shelves.Add(new GameObject("Shelf")); } }
public override void AddInteractions(InteractionObjectPair iop, Sim actor, Bookshelf target, List<InteractionObjectPair> results) { if (actor.SimDescription.TeenOrAbove && (target.Inventory.AmountIn<BookToddler>() != 0x0)) { List<Sim> list = new List<Sim>(); foreach (Sim sim in actor.LotCurrent.GetSims()) { if (sim.SimDescription.Toddler) { bool found = false; foreach (BookToddler book in Inventories.QuickDuoFind<BookToddler,Book>(target.Inventory)) { if (!ReadBookData.HasSimFinishedBook(sim, book.Data.ID)) { found = true; } } if (found) { list.Add(sim); } } } if (list.Count != 0x0) { if (list.Count == 0x1) { results.Add(new InteractionObjectPair(new Definition(list[0x0], Bookshelf_ReadToToddler.LocalizeString("ReadWith", new object[] { list[0x0] }), new string[0x0]), target)); } else { foreach (Sim sim2 in list) { results.Add(new InteractionObjectPair(new Definition(sim2, sim2.SimDescription.FirstName, new string[] { Common.LocalizeEAString("Gameplay/Objects/BookToddler:ReadWithMenuText") }), target)); } } } } }
public override string GetInteractionName(Sim actor, Bookshelf target, InteractionObjectPair iop) { return base.GetInteractionName(actor, target, new InteractionObjectPair(sOldSingleton, target)); }
public override bool Test(Sim a, Bookshelf target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool found = false; List<IGameObject> topStackItems = target.Inventory.GetTopStackItems(); foreach (IGameObject obj in topStackItems) { Book book = obj as Book; if (book == null) continue; if ((book is BookGeneral) || (book is BookWritten)) { ReadBookData data; if (a.ReadBookDataList.TryGetValue(book.Data.ID, out data)) { if (data.TimesRead == 0) { found = true; break; } } else { found = true; break; } } } return found; }
public BookshelfRecyclerViewAdapter(Bookshelf pBookshelf) { bookshelf = pBookshelf; background = typedValue.ResourceId; }