public ActionResult Edit(int id, ShowEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ShowId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateShowService(); if (service.UpdateShow(model)) { TempData["SaveResult"] = "The show was updated"; return(RedirectToAction("Index")); } var artistList = new SelectList(service.Artists(), "ArtistId", "ArtistName", model.Artist.ArtistId); ViewBag.ArtistId = artistList; return(View()); }
//Get: Edit public ActionResult Edit(int id) { var showService = NewShowService(); var detail = showService.GetShowByID(id); var model = new ShowEdit { ShowID = detail.ShowID, ShowName = detail.ShowName, Venue = detail.Venue, VenueID = detail.VenueID, VenueName = detail.Venue.VenueName, VenueType = detail.Venue.VenueType, Location = detail.Venue.Location, DateOfShow = detail.DateOfShow, ListOfArtist = detail.ListOfArtist }; var venueService = NewVenueService(); ViewBag.VenueID = new SelectList(venueService.GetVenues(), "VenueID", "VenueName", model.VenueID); var showDetail = showService.GetShowByID(model.ShowID); { // ViewBag.HeadLiningArtist = new SelectList(showDetail.ListOfArtist, "ArtistName", "ArtistName"); } return(View(model)); }
public ActionResult Edit(int id, ShowEdit model) { //Needs DateTime Functionality var venueService = NewVenueService(); if (!ModelState.IsValid) { ViewBag.VenueID = new SelectList(venueService.GetVenues(), "VenueID", "VenueName"); return(View(model)); } if (model.ShowID != id) { ModelState.AddModelError("", "Id Mismatch"); ViewBag.VenueID = new SelectList(venueService.GetVenues(), "VenueID", "VenueName"); return(View(model)); } var service = NewShowService(); if (service.UpdateShow(model)) { TempData["SaveResult"] = "Your show was updated."; ViewBag.VenueID = new SelectList(venueService.GetVenues(), "VenueID", "VenueName"); return(RedirectToAction("Edit", id)); } ViewBag.VenueID = new SelectList(venueService.GetVenues(), "VenueID", "VenueName"); ModelState.AddModelError("", "Your show could not be updated."); return(View()); }
public IHttpActionResult Put(ShowEdit show) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateShowService(); if (!service.UpdateShow(show)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateShow(ShowEdit model) { using (var ctx = new ApplicationDbContext()) { Show show = ctx.Shows.Single(e => e.ID == model.ID); show.Name = model.Name; show.TargetAge = model.TargetAge; show.Capacity = model.Capacity; show.RunTime = model.RunTime; show.AreaId = model.AreaId; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateShowService(); var detail = service.GetShowById(id); var model = new ShowEdit { ShowId = detail.ShowId, ShowName = detail.ShowName, DirectorName = detail.DirectorName, Duration = detail.Duration, GenreOfShow = detail.GenreOfShow, DateRelease = detail.DateRelease }; return(View(model)); }
public bool UpdateShow(ShowEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Shows .Single(e => e.ShowId == model.ShowId && e.OwnerId == _userId); entity.ShowName = model.ShowName; entity.DirectorName = model.DirectorName; entity.Duration = model.Duration; entity.DateRelease = model.DateRelease; entity.GenreOfShow = model.GenreOfShow; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
// GET: Edit Movie public ActionResult Edit(int?id) { ShowService service = new ShowService(); ShowDetail detail = service.GetShowById(id); ShowEdit show = new ShowEdit() { Id = detail.Id, Title = detail.Title, Description = detail.Description, PosterUrl = detail.PosterUrl, NextReleaseDate = detail.NextReleaseDate, Franchise = detail.Franchise, AnticipationValue = detail.AnticipationValue }; return(View(show)); }
public bool UpdateShow(ShowEdit model) { using (var ctx = new ApplicationDbContext()) { var show = ctx .Shows .Single(s => s.Id == model.Id); show.Title = model.Title; show.Description = model.Description; show.Genre = model.Genre; show.PosterUrl = model.PosterUrl; show.NextReleaseDate = model.NextReleaseDate; show.Franchise = model.Franchise; show.AnticipationValue = model.AnticipationValue; return(ctx.SaveChanges() == 1); } }
public bool UpdateShow(ShowEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Shows .Single(e => e.ShowId == model.ShowId && e.OwnerId == _userId); entity.ArtistId = model.ArtistId; entity.Title = model.Title; entity.CityOfVenue = model.CityOfVenue; entity.Date = model.Date; entity.Cost = model.Cost; entity.Sales = model.Sales; return(ctx.SaveChanges() == 1); } }
public bool UpdateShow(ShowEdit model) { var artistService = new ArtistService(); using (var ctx = new ApplicationDbContext()) { var entity = ctx.Shows.Single(e => e.ShowID == model.ShowID); entity.ShowName = model.ShowName; //need if statement to query database and see if a Show with that Name Exists. Drop Down Window won't work because you're changing the name of a show to one that doesn't exist. entity.VenueID = model.VenueID; entity.DateOfShow = model.DateOfShow; // entity.HeadLiningArtist = model.HeadLiningArtist; // need code for adding an Artist through ArtistShowData return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = CreateShowService(); var detail = service.GetShowById(id); var model = new ShowEdit { ShowId = detail.ShowId, Artist = detail.Artist, CityOfVenue = detail.CityOfVenue, Date = detail.Date, Cost = detail.Cost, Sales = detail.Sales }; var artistList = new SelectList(service.Artists(), "ArtistId", "ArtistName", detail.ArtistId); ViewBag.ArtistId = artistList; return(View(model)); }
public ActionResult Edit(int ID) { var service = CreateShowService(); var detail = service.GetShowByID(ID); var model = new ShowEdit { ShowID = detail.ShowID, Title = detail.Title, MainCast = detail.MainCast, Description = detail.Description, YearReleased = detail.YearReleased, YearStarted = detail.YearStarted, YearFinished = detail.YearFinished, IsRecommended = detail.IsRecommended, ModifiedUtc = DateTimeOffset.UtcNow }; return(View(model)); }
public ActionResult Edit(int id, ShowEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.ShowId != id) { ModelState.AddModelError("", "Id Mismatch"); } var service = CreateShowService(); if (service.UpdateShow(model)) { TempData["SaveResult"] = "Your Show was updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Show could not be updated"); return(View()); }
public bool UpdateShow(ShowEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Shows .Single(e => e.ShowID == model.ShowID); // && e.OwnerID == _userID);//This is Linq entity.ShowID = model.ShowID; entity.Title = model.Title; entity.MainCast = model.MainCast; entity.Description = model.Description; entity.YearReleased = model.YearReleased; entity.YearStarted = model.YearStarted; entity.YearFinished = model.YearFinished; entity.IsRecommended = model.IsRecommended; entity.ModifiedUtc = DateTimeOffset.UtcNow; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id, ShowEdit model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Could not update show, try again later"); return(View(model)); } if (model.Id != id) { ModelState.AddModelError("", "Id Mismatch"); } ShowService service = new ShowService(); if (service.UpdateShow(model)) { return(RedirectToAction("AllShows")); } ModelState.AddModelError("", "Could not update show, try again later"); return(View(model)); }