コード例 #1
0
ファイル: MainWindow.xaml.cs プロジェクト: mort79f8/WpfDapper
        private void CreateMovieBtn_Click(object sender, RoutedEventArgs e)
        {
            CreateMovie createMovie = new CreateMovie();

            createMovie.Owner = this;
            createMovie.Show();
        }
コード例 #2
0
ファイル: AddMovie.cs プロジェクト: colindj1120/MovieDatabase
        private void addMovieButton_Click(object sender, EventArgs e)
        {
            Thread t1 = new Thread(new ThreadStart(() =>
            {
                process = new ProcessingForm();
                process.ShowDialog();
            }));
            Thread t2 = new Thread(new ThreadStart(() =>
            {
                if (fileName.Length == 0 && folderPath.Length == 0)
                {
                    MessageBox.Show("Please make sure you select a file OR a folder path");
                    return;
                }
                else if (fileName.Length > 0 && folderPath.Length == 0)
                {
                    string[] split = fileName.Split('\\');
                    int index      = split[split.Length - 1].LastIndexOf('.');
                    string sub     = split[split.Length - 1].Substring(0, index);
                    CreateMovie.createMovie(sub, movieList);
                }
                else if (fileName.Length == 0 && folderPath.Length > 0)
                {
                    List <string> movies = new List <string>();
                    ProcessDirectory.processDirectory(folderPath, movies);
                    foreach (string file in movies)
                    {
                        CreateMovie.createMovie(file, movieList);
                    }
                }
                else
                {
                    CreateMovie.createMovie(fileName, movieList);
                }
                paused = false;
            }));

            t1.Start();
            t2.Start();

            while (paused == true)
            {
            }
            Invoke(new Action(() =>
            {
                process.timer.Stop();
                process.timer.Enabled = false;
                process.Dispose();
            }));
            t1.Abort();
            t2.Abort();

            /**
             *
             * save movie list to xml
             *
             **/

            Dispose();
        }
コード例 #3
0
        public async Task <MovieVm> Handle(CreateMovie request, CancellationToken cancellationToken)
        {
            var artists = _artistRepository.List(x => request.Actors.Contains(x.Id)).ToList();
            var movie   = new Movie(Guid.NewGuid(), request.Name, request.ReleaseYear, request.Duration, request.Summary, request.Country, request.MovieGenres);

            movie.Actors = artists;
            string imageUrl;

            if (request.Poster?.HasValue() == true)
            {
                if (!string.IsNullOrEmpty(movie.Poster))
                {
                    await _fileUtils.RemoveByUrlAsync(movie.Poster);
                }

                var fileName = $"movies/{Guid.NewGuid()}{request.Poster.Name.GetExtension()}";

                imageUrl = await _fileUtils.UploadAsync(request.Poster, fileName);

                if (imageUrl.IsNull())
                {
                    throw new Exception("Erro ao Importar o poster");
                }
            }
            else
            {
                imageUrl = movie.Poster;
            }
            movie.Poster = imageUrl;
            movie        = await _movieRepository.AddAsync(movie);

            return(movie.ToVm());
        }
コード例 #4
0
ファイル: MovieController.cs プロジェクト: smolsoon/CinemaApp
        public async Task <IActionResult> Post([FromBody] CreateMovie command)
        {
            command.MovieId = Guid.NewGuid();
            await _movieService.CreateAsync(command.MovieId, command.Title, command.Description, command.Type, command.Director, command.Producer, command.DateTime);

            //await _movieService.AddTicketsAsync(command.MovieId, command.Tickets, command.Price);
            return(Created($"/movies/{command.MovieId}", null));
        }
コード例 #5
0
        public static void Handle(Func <IEventPublisher> bus, CreateMovie msg)
        {
            // Todo: Validation

            var @event = new MovieCreated(Guid.NewGuid(), msg.Title, msg.ReleaseDate, msg.Genre, msg.Price);

            bus().Publish(@event);
        }
コード例 #6
0
        public async Task CreateMovie(CreateMovie command)
        {
            var director = _directorRepository.GetAsync(command.DirectorId);
            var movie    = await _movieRepository.CreateAsync(command.Title, command.DurationMinutes);

            movie.SetDirector(await director);

            await _movieRepository.AddMovie(movie);
        }
コード例 #7
0
        public async Task <IActionResult> SendCreateMovieCommand(
            [FromBody] CreateNewMovie source,
            [FromServices] IMessageBus messageBus)
        {
            CreateMovie command = Translate(source);
            await messageBus.Send(new Envelope(command));

            return(Accepted(uri: $"api/queries/Movies/{command.MovieId}"));
        }
コード例 #8
0
        public ActionResult Create([Bind(Include = "Id,Title,Year,Genre,Price")] MovieVm vm)
        {
            if (ModelState.IsValid)
            {
                var command = new CreateMovie(Guid.NewGuid(), vm.Title, new DateTime(vm.Year, 1, 1), vm.Genre, vm.Price);
                _commandSender.Send(command);
                return(RedirectToAction("Index"));
            }

            return(View(vm));
        }
コード例 #9
0
ファイル: MoviesController.cs プロジェクト: jeftenunes/eMovie
        public async Task <IActionResult> Post([FromBody] CreateMovie createMovie)
        {
            try
            {
                await busClient.PublishAsync(createMovie);

                return(Accepted($"api/movies/{createMovie.Id}"));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
コード例 #10
0
        public Movie Handle(CreateMovie command)
        {
            var movie = _eventStoreRepository.GetMovie(command.MovieId);

            if (!string.IsNullOrEmpty(movie.Id))
            {
                return(movie);
            }

            movie = new Movie(command.MovieId, command.Title, command.Seats);
            _eventStoreRepository.Save(movie);

            return(movie);
        }
コード例 #11
0
        public async Task create_movie()
        {
            var command = new CreateMovie()
            {
                DurationMinutes = 123,
                Title           = "test movie"
            };

            var payload  = GetPayload(command);
            var response = await Client.PostAsync(apiUrl, payload);

            Assert.AreEqual(HttpStatusCode.Created, response.StatusCode);
            Assert.AreEqual(apiUrl, response.Headers.Location.ToString());
        }
コード例 #12
0
        public async Task CreateMovie_command_handler_creates_Movie_aggregate_root(
            CreateMovie command)
        {
            IEventSourcedRepository <Movie>
                repository = GetRepository(Movie.Factory);
            var sut        = new MovieCommandHandler(
                repository, GetRepository(Theater.Factory));

            await sut.Handle(new Envelope(command));

            Movie actual = await repository.Find(command.MovieId);

            actual.Should().NotBeNull();
            actual.Title.Should().Be(command.Title);
        }
コード例 #13
0
        private void ExecuteAddMovieCommand()
        {
            var result = GetMovieFromInputDialog();

            result.Match(
                onChoice1Of2: x =>
            {
                var createMovie = new CreateMovie(x.Id, x.Title, new DateTime(Int32.Parse(x.ReleaseDate), 1, 1), x.Genre, x.Price);
                _commandSender.Send(createMovie);
                _movies.Add(x);
            },
                onChoice2Of2: err =>
            {
                if (err == MovieInputError.ParsingError)
                {
                    MessageBox.Show("An error occurred. Wrong input.");
                }
            });
        }
コード例 #14
0
        public void CreateMovie()
        {
            //Create movie
            var movieId            = Guid.NewGuid().ToString();
            var createMovieCommand = new CreateMovie
            {
                MovieId = movieId,
                Title   = "Batman",
                Seats   = 10
            };
            var movie = _movieHandler.Handle(createMovieCommand);

            Assert.AreEqual(movie.Id, movieId);
            Assert.AreEqual(movie.Title, "Batman");
            Assert.AreEqual(movie.AvaliableSeats, 10);

            // Book 2 seats
            var bookTwoSeatsCommand = new BookSeats
            {
                MovieId = movieId,
                Seats   = 2
            };

            movie = _movieHandler.Handle(bookTwoSeatsCommand);

            Assert.AreEqual(movie.AvaliableSeats, 8);

            // Cant book more seats than available
            var bookTooManySeats = new BookSeats
            {
                MovieId = movieId,
                Seats   = 10
            };

            movie = _movieHandler.Handle(bookTooManySeats);

            Assert.AreEqual(movie.AvaliableSeats, 8);

            // Book 4 seats
            var bookFourSeatsCommand = new BookSeats
            {
                MovieId = movieId,
                Seats   = 4
            };

            _movieHandler.Handle(bookFourSeatsCommand);

            // How many seats booked
            var seatsBooked = _views.GetSeatsBookedFor(movieId);

            Assert.AreEqual(seatsBooked, 6);

            // Create a snapshot
            _snapshotGenerator.SnapshotMovieAggregate(movieId);

            // Get events from snapshot aggregate
            seatsBooked = _views.GetSeatsBookedFor(movieId);
            Assert.AreEqual(seatsBooked, 6);

            // Book 1 seats
            var bookOneSeatCommand = new BookSeats
            {
                MovieId = movieId,
                Seats   = 1
            };

            movie = _movieHandler.Handle(bookOneSeatCommand);
            Assert.AreEqual(movie.AvaliableSeats, 3);

            // Book 1 seats
            movie = _movieHandler.Handle(bookOneSeatCommand);
            Assert.AreEqual(movie.AvaliableSeats, 2);

            // Create a new snapshot
            _snapshotGenerator.SnapshotMovieAggregate(movieId);

            // Book 1 seats
            movie = _movieHandler.Handle(bookOneSeatCommand);
            Assert.AreEqual(movie.AvaliableSeats, 1);
        }
コード例 #15
0
 public async Task <IActionResult> Post([FromBody] CreateMovie command)
 {
     return(command == null?
            UnprocessableEntity()
                : Ok(await _mediator.Send(command)));
 }
コード例 #16
0
 public IHttpActionResult Create(CreateMovie command)
 {
     _repository.CreateMovie(command);
     return(Ok());
 }
コード例 #17
0
        static void Main(string[] args)
        {
            if (SQL.CheckConnection())
            {
                SQL.CreateDatabase();
            }

            int      homeChoice, typeChoice, usrActionChoice, admActionChoice, newOldChoice;
            Customer customer;

            do
            {
                homeChoice = PickStart.View();
                if (homeChoice == 0)
                {
                    typeChoice = PickUserType.View();
                    if (typeChoice == 0)
                    {
                        newOldChoice = PickNewOrOldCustomer.View();
                        if (newOldChoice == 0)
                        {
                            customer = CustomerLogin.View();
                        }
                        else
                        {
                            customer = CreateCustomer.View();
                        }
                        ShowCustomer.View(customer);
                        do
                        {
                            usrActionChoice = PickCustomerActions.View();
                            switch (usrActionChoice)
                            {
                            case 0:
                                CreateBooking.View(customer);
                                break;

                            case 1:
                                ShowCustomerBookings.View(customer);
                                break;

                            case 2:
                                customer = UpdateCustomer.View(customer);
                                break;

                            case 3:
                                Delete.Customer(customer.CustomerId);
                                usrActionChoice = 4;
                                break;

                            default:
                                break;
                            }
                        } while (usrActionChoice != 4);
                    }
                    else if (typeChoice == 1)
                    {
                        do
                        {
                            admActionChoice = PickAdminActions.View();
                            switch (admActionChoice)
                            {
                            case 0:
                                CreateMovie.View();
                                break;

                            case 1:
                                ShowCustomers.View();
                                break;

                            default:
                                break;
                            }
                        } while (admActionChoice != 2);
                    }
                }
            } while (homeChoice == 0);
        }
コード例 #18
0
 public void CreateMovie(CreateMovie command)
 {
     RunStatementInTransaction(
         $"CREATE (x:{Movie} {CreateProperty(Title, command.Title)}) RETURN x");
 }
コード例 #19
0
 public IMovieModel Any(CreateMovie request)
 {
     return(workflow.Create(request));
 }
コード例 #20
0
        public async Task <IActionResult> Save([FromBody] CreateMovie command)
        {
            await DispatchAsync(command);

            return(Created("api/Movies", null));
        }