public async Task <IActionResult> Create([Bind("Id,Name,Family,Surname,DateBirth")] Author author) { if (ModelState.IsValid) { _context.Add(author); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(author)); }
public async Task <IActionResult> AddCommentaryBook(AddCommentaryOnBookViewModel vm) { if (ModelState.IsValid && vm.rating != 0) { // Если юзер авторизован, то оставить комментарий if (User.Identity.IsAuthenticated) { // Далее добавляем комментарий в бд await context.Ratings.AddAsync(new Rating() { IdBook = vm.IdBook, IdUser = User.Identity.Name, Mark = (byte)vm.rating, Comment = vm.Commentary }); await context.SaveChangesAsync(); return(Redirect($"~/Books/AboutBook?id={vm.IdBook}"));; } } return(await AboutBook(vm.IdBook)); }
public async void AddUserVisit(string IdUser, int IdBook) { await Task.Run(() => { db.UsersVisit.AddAsync(new visitUser() { DateVisit = DateTime.Now, IdBook = IdBook, IdUser = IdUser }); db.SaveChangesAsync(); }); }