public ActionResult AddFeatures(TeamFeaturesModel model) { if (ModelState.IsValid) { var addFeature = new PlayDetailsBL(); var addfeatureModel = new TeamManagement.BO.PlayDetail { Season = model.Season, TeamAgainst = model.PlayingAgainst, Venue = model.Venue, TeamId = model.TeamId, FixtureDate = model.Date, // HomeTeam = model.HomeTeam }; string message = addFeature.Insert(addfeatureModel); if (message.Equals(String.Empty)) { model.isSuccessMessage = true; model.errorMessage = "Team Successfully added"; return(View(model)); } else { model.isSuccessMessage = false; model.errorMessage = message; return(View(model)); } } model.HomeTeam = Session["HomeTeam"].ToString(); return(View(model)); }
//public JsonResult GetPersonInformations() //{ // var listOfPlayers = new PlayerDetailsBL(); // var playerDetailsList = new List<PlayerDetailsList>(); // var playerDetails = listOfPlayers.GetALL(); // foreach (var player in playerDetails) // { // playerDetailsList.Add // ( // new PlayerDetailsList // { // Id = player.id, // DateOfBirth = player.DateOfBirth, // FirstName = player.FirstName, // LastName = player.LastName, // Weight = player.Weight, // Height = player.Height, // Notes = player.Notes // }); // } // return Json(playerDetailsList, JsonRequestBehavior.AllowGet); //} #endregion public JsonResult GetFeaturesAndScores() { var playDetails = new PlayDetailsBL(); var model = new List <TeamFeaturesModel>(); var teamDetails = new TeamDetailsBL(); var result = playDetails.GetALL(); foreach (var detail in result) { model.Add ( new TeamFeaturesModel { HomeTeam = teamDetails.GetByID((int)detail.TeamId).TeamName, // Session["HomeTeam"].ToString(), PlayingAgainst = detail.TeamAgainst, Season = teamDetails.GetByID((int)detail.TeamId).SeasonYear, Venue = (detail.Venue ?? "").ToString(), id = detail.Id, AwayTeamScore = (detail.AwayScore ?? "").ToString(), Date = (System.DateTime)detail.FixtureDate, HomeScore = (detail.HomeScore ?? "").ToString() }); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public ActionResult UpdateScores(TeamFeaturesModel model) { // var errors = ModelState.Values.SelectMany(v => v.Errors); // var errors2 = ModelState.Where(x => x.Value.Errors.Count > 0).Select(x => new { x.Key, x.Value.Errors }).ToArray(); // if (ModelState.IsValid) // { var updateScores = new PlayDetailsBL(); var updateScoresModel = new TeamManagement.BO.PlayDetail { HomeScore = model.HomeScore, AwayScore = model.AwayTeamScore, Id = model.id }; string message = updateScores.Update(updateScoresModel); if (message.Equals(String.Empty)) { model.isSuccessMessage = true; TempData["SuccessMessage"] = "Scores successfully updated"; return(RedirectToAction("AddFeatures")); } else { model.isSuccessMessage = false; TempData["ErrorMessage"] = message; return(RedirectToAction("AddFeatures")); } // } // return View(); }