Esempio n. 1
0
        public async Task <bool> CreateAccount(Account account)
        {
            try
            {
                _context.Accounts.Add(account);
                await _context.SaveChangesAsync();
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        public async Task <bool> AddReview(Review review)
        {
            bool   output         = false;
            Review existingReview = null;

            try
            {
                existingReview = await _context.Reviews
                                 .Where(x => x.AccountId == review.AccountId && x.VideoId == review.VideoId)
                                 .FirstOrDefaultAsync();

                if (existingReview != null)
                {
                    existingReview.Description = review.Description;
                    existingReview.Rating      = review.Rating;
                }
                else
                {
                    _context.Reviews.Add(review);
                }

                await _context.SaveChangesAsync();

                output = true;
            }
            catch (Exception) { }

            return(output);
        }
        public async Task <bool> AddRental(VideoRental rental)
        {
            bool output = false;

            try
            {
                _context.VideoRentals.Add(rental);
                await _context.SaveChangesAsync();

                output = true;
            }
            catch (Exception) { }

            return(output);
        }