public async Task <IActionResult> PutActor(int id, Actor actor) { if (id != actor.Id) { return(BadRequest()); } _context.Entry(actor).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ActorExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMovie(int id, Movie movie) { if (id != movie.MovieID) { return(BadRequest()); } _context.Entry(movie).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MovieExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutShowing(int id, Showing showing) { if (id != showing.ShowingID) { return(BadRequest()); } _context.Entry(showing).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ShowingExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult> Edit([Bind(Include = "ID,Name,Adress")] Venue venue) { if (ModelState.IsValid) { db.Entry(venue).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(venue)); }
public async Task <ActionResult> Edit([Bind(Include = "ID,MovieId,VenueId,ScreeningStart,ScreeningEnd,BasePrice,IsPremiere,SubtitleLanguage,Language")] Screening screening) { if (ModelState.IsValid) { db.Entry(screening).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.MovieId = new SelectList(db.Movies, "ID", "Title", screening.MovieId); ViewBag.VenueId = new SelectList(db.Venues, "ID", "Name", screening.VenueId); return(View(screening)); }
public async Task <ActionResult <UserViewModel> > Register([FromForm] RegisterViewModel registerDetails) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (!Role.AllRoles.Contains(registerDetails.Role)) { return(BadRequest()); } if (!CheckPasswordRequirements(registerDetails.Password)) { return(BadRequest()); } var resultUser = new User { UserName = encoder.Encode(registerDetails.Username), FullName = encoder.Encode(registerDetails.FullName), }; context.Users.Add(resultUser); var createResult = await userManager.CreateAsync(resultUser, registerDetails.Password); if (!createResult.Succeeded) { return(BadRequest()); } var roleResult = await userManager.AddToRoleAsync(resultUser, registerDetails.Role); if (!roleResult.Succeeded) { return(BadRequest()); } context.Entry(resultUser).State = EntityState.Modified; await context.SaveChangesAsync(); if (resultUser != null) { return(new OkObjectResult(new UserViewModel(resultUser, encoder, registerDetails.Role))); } else { return(BadRequest()); } }
public async Task <ActionResult> Edit([Bind(Include = "ID,Title,ReleaseDate,GenreId,Rating,Description,YouTubeLink")] Movie movie, HttpPostedFileBase upload) { var avatar = new Models.File(); if (upload != null && upload.ContentLength > 0) { avatar = new Models.File { Movie = movie, MovieId = movie.ID, FileName = System.IO.Path.GetFileName(upload.FileName), FileType = FileType.Stock, ContentType = upload.ContentType }; using (var reader = new System.IO.BinaryReader(upload.InputStream)) { avatar.Content = reader.ReadBytes(upload.ContentLength); } if (movie.Files != null) { movie.Files = null; db.Files.Remove(movie.Files.FirstOrDefault()); } movie.Files = new List <Models.File> { avatar }; } if (ModelState.IsValid) { db.Entry(movie).State = EntityState.Modified; await db.SaveChangesAsync(); db.Files.Add(avatar); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.GenreId = new SelectList(db.Genres, "ID", "Name", movie.GenreId); return(View(movie)); }