public IActionResult Create(GameAddViewModel model) { if (!this.ModelState.IsValid) { //ugly code because of the usage of the index page as a "multytool" var errors = this.ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage); this.TempData.AddErrorMessage(string.Join(Environment.NewLine, errors)); return(this.RedirectToAction("Index")); } this.gameService.Create(model.Theme, model.PlayersCount, model.UserId); return(this.RedirectToAction("Index", new { search = model.Theme })); }
public IHttpActionResult PostSaveGame(GameAddViewModel model) { if (ModelState.IsValid) { var gameSave = new GameItemViewModel { id = 3, title = model.Title, image = model.Image }; return(Content(HttpStatusCode.OK, model)); } return(Content(HttpStatusCode.BadRequest, new { title = "має бути", image = "теж саме" })); }