public ActionResult Save(PlayerEditModel form) { if (ModelState.IsValid) { var dto = Mapper.Map<PlayerEditModel, PlayerDto>(form); IOperationResult result = _playersService.SavePlayer(dto); //other option here would be something like this //if (form.Id == Guid.Empty) //{ // result = _playersService.AddPlayerToClub(dto); //} //else //{ // result = _playersService.EditClubMemberProfile(dto); //} if (result.Success) { return RedirectToAction("Index"); } ModelState.AddModelErrors(result.ValidationFaults); //maybe do here other come complex logic if necessary } //if fail if (form.Id == Guid.Empty) return View("Create", form); return View("Edit", form); }
public void GivenIEnterTheFollowingInformationForANewPlayer(Table table) { var player = new PlayerEditModel { ContactPhoneNumber = table.Rows[0]["ContactNo"], Email = table.Rows[0]["Email"], JoinDate = DateTime.Parse(table.Rows[0]["JoinDate"]), Name = table.Rows[0]["Name"], StreetAddress = table.Rows[0]["Address"] }; if (ScenarioContext.Current.ContainsKey("plr1")) { var scrabblePlayer = ScenarioContext.Current["plr1"] as ScrabblePlayer; if (scrabblePlayer != null) { var id = scrabblePlayer.Id; player.Id = id; //set the ID in edit mode } } ScenarioContext.Current["addplr"] = player; }