Пример #1
0
        public async Task <bool> Add(int userId)
        {
            var addedSubscription = _context.Subscriptions
                                    .Add(new SubscriptionViewModel
            {
                UserId = userId
            });

            await _context.SaveChangesAsync();

            return(addedSubscription != null);
        }
Пример #2
0
        public async Task <bool> AddUser(User user)
        {
            var newUser = new UserViewModel
            {
                Username = user.Username,
                Password = user.Password
            };

            var addedUser = _context.Users.Add(newUser);
            await _context.SaveChangesAsync();

            return(addedUser != null);
        }
Пример #3
0
        public async Task <bool> AddBook(Book book)
        {
            var bookViewModel = new BookViewModel
            {
                Name        = book.Name,
                Author      = book.Author,
                Description = book.Description,
                ImageUrl    = book.ImageUrl,
                Rating      = book.Rating,
            };
            var addedBook = _context.Books.Add(bookViewModel);
            await _context.SaveChangesAsync();

            return(addedBook != null);
        }