private GameTable GetGameTable(GameTableViewModel gameTableViewModel, Gamer gamer) { var result = Mapper.Map <GameTable>(gameTableViewModel); Mapper.Map(gamer, result); return(result); }
public JsonResult Add(GameTableViewModel model) { if (ModelState.IsValid) { if (!(Session["gamer"] is Gamer gamer)) { return(Json(Errors.GamerNotLoggedIn, JsonRequestBehavior.AllowGet)); } var gameTable = GetGameTable(model, gamer); var tableBoardGameIdList = model.TableBoardGameList.Select(x => x.BoardGameId).ToList(); _gameTableService.CreateGameTable(gameTable, tableBoardGameIdList); return(Json(null, JsonRequestBehavior.AllowGet)); } var errors = Helpers.GetErrorMessages(ModelState.Values); return(Json(errors, JsonRequestBehavior.AllowGet)); }