示例#1
0
        /// <summary>
        /// Cadastra um novo Filme.
        /// </summary>
        /// <param name="movie">filme para ser cadastrado</param>
        /// <returns>O filme que foi cadastrado</returns>
        public async Task <Result <Exception, Movie> > AddAsync(Movie movie)
        {
            var newMovie = _context.Movies.Add(movie).Entity;

            var saveChangesCallback = await Result.Run(async() => await _context.SaveChangesAsync());

            if (saveChangesCallback.IsFailure)
            {
                return(saveChangesCallback.Failure);
            }

            return(newMovie);
        }
示例#2
0
        /// <summary>
        /// Cadastra um novo Genero.
        /// </summary>
        /// <param name="genre">genero para ser cadastrado</param>
        /// <returns>O genero que foi cadastrado</returns>
        public async Task <Result <Exception, Genre> > AddAsync(Genre genre)
        {
            var newGenre = _context.Genres.Add(genre).Entity;

            var saveChangesCallback = await Result.Run(async() => await _context.SaveChangesAsync());

            if (saveChangesCallback.IsFailure)
            {
                return(saveChangesCallback.Failure);
            }

            return(newGenre);
        }
示例#3
0
        /// <summary>
        /// Cadastra um novo aluguel.
        /// </summary>
        /// <param name="movie">aluguel para ser cadastrado</param>
        /// <returns>O aluguel que foi cadastrado</returns>
        public async Task <Result <Exception, Rent> > AddAsync(Rent rent)
        {
            var newRent = _context.Rents.Add(rent).Entity;

            var saveChangesCallback = await Result.Run(async() => await _context.SaveChangesAsync());

            if (saveChangesCallback.IsFailure)
            {
                return(saveChangesCallback.Failure);
            }

            return(newRent);
        }