예제 #1
0
        private void AddMovie()
        {
            if (CheckPosition())
            {
                double price;
                int    rate;
                if (!double.TryParse(PriceTb.Text.Replace('.', ','), out price))
                {
                    IncoretPrice.Visible = true;
                }
                else
                {
                    IncoretPrice.Visible = false;
                }
                if (!int.TryParse(RateTb.Text, out rate))
                {
                    IncoretRate.Visible = true;
                }
                else
                {
                    IncoretRate.Visible = false;
                }
                if (double.TryParse(PriceTb.Text.Replace('.', ','), out price) &&
                    int.TryParse(RateTb.Text, out rate))
                {
                    Movie movie = new Movie()
                    {
                        Name        = NameTb.Text.Replace(' ', '_'),
                        Price       = double.Parse(PriceTb.Text.Replace('.', ',')),
                        Description = DescriptionTb.Text.Replace(' ', '_'),
                        Rate        = int.Parse(RateTb.Text)
                    };
                    _movieDb.AddMovie(movie);
                    MessageBox.Show("Pomyślnie dodano film");
                    this.Close();
                }
            }

            else
            {
                if (_movieErrors.NameError)
                {
                    IncoretName.Visible = true;
                }
                if (_movieErrors.PriceError)
                {
                    IncoretPrice.Visible = true;
                }
                if (_movieErrors.DescriptionError)
                {
                    IncoretDescription.Visible = true;
                }
                if (_movieErrors.RateError)
                {
                    IncoretRate.Visible = true;
                }
            }
        }
예제 #2
0
        public IActionResult Post([FromForm] Movie movie)
        {
            if (movie.Image != null)
            {
                movie.ImageUrl = _movieRepo.SaveImage(movie.Image);
            }

            _movieRepo.AddMovie(movie);
            _movieRepo.Save();



            return(StatusCode(StatusCodes.Status201Created));
        }
        public IActionResult Post(Movie movie)
        {
            if (!string.IsNullOrEmpty(movie.PosterPath))
            {
                string fileName = Guid.NewGuid() + ".jpg";
                string fullPath = Path.Combine(posterFolderPath, fileName);

                byte[] imageBytes = Convert.FromBase64String(movie.PosterPath);
                System.IO.File.WriteAllBytes(fullPath, imageBytes);

                movie.PosterPath = fileName;
            }
            else
            {
                movie.PosterPath = _config["DefaultPoster"];
            }

            _movieService.AddMovie(movie);

            return(Ok());
        }
예제 #4
0
        public HttpResponseMessage Post(MovieModel movie)
        {
            var _result = iMovie.AddMovie(movie);

            return(Request.CreateResponse(HttpStatusCode.OK, _result));
        }