static void Main(string[] args) { List <Movie> movies = new List <Movie>(); IMovieManager movieManager = new MovieManager(); var scraped = ScraperBuilder.Builder() .WithDefaultLoadersParsers() .WithDefaultScrapedDataManager() .Build() .Scrape(); foreach (var scrapedItem in scraped) { var movie = movieManager.Create(scrapedItem); var showtimeManager = new ShowtimeManager(movie, new DateBuilder()); showtimeManager.UpdateShowtimes(scrapedItem); movies.Add(movie); } try { // sample of scraped data can be found in ./scrapedData.json var json = JsonConvert.SerializeObject(movies, Formatting.Indented); } catch (Exception e) { LogHelper.Error("Program", e.ToString()); throw; } }
[HttpPost] // post nozīmē datu iesūtīšana public ActionResult Edit(MovieModel model) { if (ModelState.IsValid) // iebūvēta funkcija, kas pārbauda vai dati atbilst definētajiem { if (model.Id != 0) // ja Id ir nav definēts, tad labojam { MovieManager.Update(model.ToData()); } else { MovieManager.Create(model.ToData()); } } return(RedirectToAction("Edit", "Cinema", new { id = model.CinemaId })); }
public ActionResult Create(Movie movie, HttpPostedFileBase PosterImage) { if (ModelState.IsValid) { if (PosterImage != null) { SaveImage(PosterImage, ref movie); _movieManager.Create(movie); return(RedirectToAction("Index")); } } return(View()); }
public ActionResult Edit(MovieModel model) { if (ModelState.IsValid) { if (model.Id == 0) { MovieManager.Create(model.ToData()); } else { MovieManager.Update(model.ToData()); } //sutam atpakal uz kino redigesanas formu return(RedirectToAction("Edit", "Cinema", new { id = model.CinemaId })); } return(View(model)); }