public Challenge Add(ChallengeInputModel challenge) { var entry = new Challenge() { Name = challenge.Name, Description = challenge.Description, StartDate = challenge.StartDate, MinimumWordsRestriction = challenge.MinimumWordsRestriction, Reward = challenge.Reward }; return this.dbContext.Challenges.Add(entry); }
public ActionResult PostNewChallenge(ChallengeInputModel challenge) { if(!ModelState.IsValid) { TempData["challengeModel"] = challenge; return this.RedirectToAction("NewChallenge"); } this.challengesService.PostNewChallenge(challenge); return this.RedirectToAction("NewChallenge"); }
public void PostNewChallenge(ChallengeInputModel challenge) { HttpContent contentPost = new StringContent(JsonConvert.SerializeObject(challenge), Encoding.UTF8, "application/json"); HttpResponseMessage response = this.httpClient.PostAsync("api/challenges/", contentPost).Result; }