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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
 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();
     });
 }