public ActionResult Add(SportSystem.Models.Match match, CommentInputModel commentInput) { var comment = Mapper.Map<Comment>(commentInput); comment.AuthorId = this.UserProfille.Id; comment.MatchId = match.Id; comment.CreatedOn = DateTime.Now; this.Data.Comments.Add(comment); this.Data.SaveChanges(); return this.RedirectToAction("Details", "Matches", new { id = match.Id }); }
public ActionResult AddBet(SportSystem.Models.Match match, int teamId, BetInputModel betInput) { if (match == null) { return this.HttpNotFound(); } if (match.HomeTeamId != teamId && match.AwayTeamId != teamId) { return this.HttpNotFound(); } var bet = Mapper.Map<Bet>(betInput); bet.UserId = this.UserProfille.Id; bet.TeamId = teamId; bet.MatchId = match.Id; this.Data.Bets.Add(bet); this.Data.SaveChanges(); var newAmmount = this.Data.Bets.All().Where(b => b.TeamId == teamId && b.MatchId == match.Id).Sum(b => b.Ammount); return this.Content(newAmmount.ToString(CultureInfo.InvariantCulture)); }