public IActionResult Create(int id, int number = 0) { var viewModel = new CreateSeriesRelatedEntityInputModel { RetrievedGenres = this.genreRetrievalService.GetAllAsKeyValuePairs(), SeriesId = id, Number = number, }; return(this.View(viewModel)); }
public async Task <IActionResult> Create(CreateSeriesRelatedEntityInputModel model) { if (!this.ModelState.IsValid) { model.RetrievedGenres = this.genreRetrievalService.GetAllAsKeyValuePairs(); return(this.View(model)); } var serviceModel = new CreateSeriesRelatedEntityServiceModel { Title = model.Title, Number = model.Number, CoverImage = await model.CoverImage.GetBytes(), CoverPath = model.CoverPath, Description = model.Description, Genres = model.Genres, SeriesId = model.SeriesId, RetrievedGenres = model.RetrievedGenres, }; try { var id = this.issueCreationService.CreateIssue(serviceModel); this.cache.RemoveSeriesDetails(model.SeriesId); return(this.Redirect($"/Issue/{id}")); } catch (KeyNotFoundException) { return(this.NotFound()); } catch (InvalidOperationException) { return(this.BadRequest()); } }