public Task RemoveFromShelf([FromBody] RemoveFromShelfRequest request) { //return _bookService.RemoveFromShelf(request, UserId); #region tmp ki lesz veve return(_bookService.RemoveFromShelf(request, request.UserIdentifier)); #endregion }
public async Task RemoveFromShelf(RemoveFromShelfRequest request, string userIdentifier) { var entity = await _context.UserBooks .FirstOrDefaultAsync(ub => ub.BookId == request.BookId && ub.UserIdentifier == userIdentifier); entity.Deleted = true; await _context.SaveChangesAsync(); }
public void OnClick(object sender, EventArgs eventArgs) { View view = (View)sender; var position = RecyclerView.GetChildAdapterPosition((View)view.Parent.Parent.Parent); PopupMenu popup = new PopupMenu(view.Context, view); popup.Inflate(Resource.Menu.menu_library_item); popup.MenuItemClick += async(clickedItem, argument) => { if (argument.Item.ItemId == Resource.Id.menuItem_libraryItem_delete) { var config = new ConfirmConfig { Title = "Törlés megerősítése", Message = "Biztosan törli ezt a könyvet?", OkText = "Törlés", CancelText = "Mégse" }; var result = await UserDialogs.Instance.ConfirmAsync(config); if (result) { var dialog = UserDialogs.Instance.Loading("Loading"); var book = Library[position]; var request = new DeleteBookByIdRequest { BookId = book.BookId, #region tmp ki lesz veve UserIdentifier = HbrApplication.UserIdentifier #endregion }; using (var client = new HttpClient()) { var response = await client.PostAsJsonAsync($"https://hbr.azurewebsites.net/api/Book/DeleteBookById", request); } _database.RemoveTable(book); Library.RemoveAt(position); NotifyDataSetChanged(); dialog.Dispose(); } } else if (argument.Item.ItemId == Resource.Id.menuItem_libraryItem_details) { var activity = new Intent(Context, typeof(BookDetailActivity)); var dto = Library[position]; XmlSerializer xmlSerializer = new XmlSerializer(typeof(ClientBookDto)); StringWriter sw = new StringWriter(); xmlSerializer.Serialize(sw, dto); activity.PutExtra("book", sw.ToString()); ((Activity)Context).StartActivityForResult(activity, BookDetailActivity.RequestCode); } else if (argument.Item.ItemId == Resource.Id.menuItem_libraryItem_updateProgress) { var config = new PromptConfig { Title = "Aktiális oldalszám módosítása!", Message = "Adja meg az aktuális oldalszámot", Text = Library[position].PageNumber.ToString(), OkText = "Mentés", CancelText = "Mégse" }; var result = await UserDialogs.Instance.PromptAsync(config); if (result.Ok) { var request = new UpdateBookProgressRequest { BookId = Library[position].BookId, #region tmp ki lesz veve UserIdentifier = HbrApplication.UserIdentifier #endregion }; try { request.NewProgress = int.Parse(result.Text); } catch (Exception) { await UserDialogs.Instance.AlertAsync(new AlertConfig { Title = "Hibás oldalszám!", Message = "Az oldalszám csak szám lehet, ezért a művelet nem lett végrehajtva!" }); return; } var dialog = UserDialogs.Instance.Loading("Loading"); using (var client = new HttpClient()) { await client.PostAsJsonAsync("https://hbr.azurewebsites.net/api/Book/UpdateBookProgress", request); } Library[position].PageNumber = request.NewProgress; dialog.Dispose(); } } else if (argument.Item.ItemId == Resource.Id.menuItem_libraryItem_removeFromShelf) { var config = new ConfirmConfig { Title = "Levétel megerősítése", Message = "Biztosan leveszi ezt a könyvet a listájáról?", OkText = "Igen", CancelText = "Mégse" }; var result = await UserDialogs.Instance.ConfirmAsync(config); if (result) { var dialog = UserDialogs.Instance.Loading("Loading"); var book = Library[position]; var request = new RemoveFromShelfRequest { BookId = book.BookId, #region tmp ki lesz veve UserIdentifier = HbrApplication.UserIdentifier #endregion }; using (var client = new HttpClient()) { var response = await client.PostAsJsonAsync($"https://hbr.azurewebsites.net/api/Book/RemoveFromShelf", request); } _database.RemoveTable(book); Library.RemoveAt(position); NotifyDataSetChanged(); dialog.Dispose(); } } }; popup.Show(); }