public async Task <IActionResult> Create([Required] UpdateFilmViewModel viewModel) { if (viewModel.PosterFile == null) { return(BadRequest()); } if (!CheckContentType(viewModel.PosterFile.ContentType)) { return(BadRequest()); } var user = await _userManager.GetUserAsync(User); if (user == null) { return(Forbid()); } var entity = new Film() { Name = viewModel.Film.Name, Description = viewModel.Film.Description, Director = viewModel.Film.Director, ReleaseYear = viewModel.Film.ReleaseYear, UserId = user.Id }; await _filmRepository.Create(entity, viewModel.PosterFile); return(RedirectToAction("Index", "Film", new { pageNum = 1, pageSize = PageSize })); }
private async Task ParseFilm(string s) { var doc = new HtmlDocument(); doc.LoadHtml(s); var section = doc.DocumentNode.SelectSingleNode("//div[@id='catalog-content']"); var films = section.SelectNodes("//div[@class='movie']"); foreach (var p in films) { var src = p.Descendants("img").First().GetAttributeValue("src", string.Empty); var name = p.Descendants("span").First().InnerText; if (string.IsNullOrEmpty(src) || string.IsNullOrEmpty(name)) { continue; } var f = await _repoFilm.Films .Where(z => z.Name == name).AnyAsync(); if (f) { continue; } _repoFilm.Create(new Film { Name = name, Src = src }); await _repoFilm.SaveChangesAsync(); } }
public IHttpActionResult Post(Film film) { try { var entity = _filmRepository.Create(film); _entityManager.Commit( ); return(Ok(entity)); } catch (Exception ex) { return(BadRequest(ex.ToString( ))); } }
public ActionResult Create(Film film, int zaalId) { ViewBag.zalen = _filmRepository.GetAllZalen(); film.Zaal = _filmRepository.GetZaal(zaalId); if (CheckFilm(film)) { _filmRepository.Create(film); return(RedirectToAction("Index")); } return(View()); }
public async Task Update(FilmUpdateModel m) { var f = await _repoFilm.Films .Where(z => z.Name == m.Name).AnyAsync(); if (f) { return; } _repoFilm.Create(new Film { Name = m.Name, Src = m.Src }); await _repoFilm.SaveChangesAsync(); }
public async Task <IActionResult> Create([Bind("ID,Title,OrtherTitle,Description, DescriptionShort,TempTag,DateofRease,Info,Length,Watch,StarRating,Video, VideoBackUp1, VideoBackUp2,VideoTrailer,Slug,ImageID,SerieID,Genres,IsProposed,Actor,Director,TempTag")] CreateEditFilmViewModel film) { if (ModelState.IsValid) { var user = await _userManager.GetUserAsync(HttpContext.User); film.AuthorID = user.Id; await _repository.Create(film); return(RedirectToAction("Index")); } ViewData["ImageID"] = new SelectList(_repository.GetImages(), "ID", "Name", film.ImageID); ViewData["AuthorID"] = new SelectList(_repository.GetMembers(), "Id", "FullName", film.AuthorID); ViewData["SerieID"] = new SelectList(_repository.GetSeries(), "ID", "ID", film.SerieID); return(View(film)); }
public int Create(Film entity) { return(_repo.Create(entity.GetFilm())); }
public void Create(Film entity) => _inner.Create(entity);
public void Create(Film entity) { _filmRepository.Create(entity); }
public int Create(Film entity) { return(_repo.Create(entity.ToGlobal())); }