public IActionResult UpdateFilm(int ID) { Film film = new Film { Name = "Transformers" }; //from db CreateOrUpdateDTO dTO = new CreateOrUpdateDTO(); dTO.Name = film.Name; return(View(dTO)); }
public IActionResult CreateFilm(CreateOrUpdateDTO model) { if (model.ID == 0) { // create a new film (filmService.create(....) } else { // update the existing film by ID } return(View(model)); }
public IActionResult CreateOrUpdate(CreateOrUpdateDTO dto) { var film = new Film() { ID = dto.ID, Name = dto.Name, Year = dto.Year, Genres = dto.Genres, IsInStore = dto.IsInStore }; if (dto.Operation == Operation.Create) { // create a new film ... Note: the ID from the dto will be ignored return(View("Created")); } else if (dto.Operation == Operation.Update) { // update the existing film by ID return(View("Updated")); } else { return(View("Error")); // we don't implement the Error view now } }