// GET: api/Score/5 //public string Get(int id) //{ // return "value"; //} // POST: api/Score public void Post([FromBody] JObject unityScoreJson) { if (User.Identity.IsAuthenticated) { var unityScore = unityScoreJson.ToObject <ScorePostModel>(); unityScore.PlayerId = User.Identity.GetUserId(); unityScore.Date = DateTime.Now; var result = _mapper.Map <ScoreModel>(unityScore); _scoreManager.CreateScore(result); } }
public ActionResult CreateScore(ScoreModel model) { ViewBag.voters = new SelectList(_votMgr.GetVoters().Result, "VoterId", "VotName"); ViewBag.restaurants = new SelectList(_restMgr.GetRestaurants().Result, "RestId", "RestName"); model.CreatedBy = User.Identity.GetUserId(); var result = _scoreMgr.CreateScore(model); if (result.Succeeded == true) { TempData["message"] = $"Score{model.ScoreId} was successfully added!"; if (User.IsInRole("Admin")) { return(RedirectToAction("Index")); } return(RedirectToAction("Index", "Home")); } return(View(model)); }