// Create Method public bool CreateEthicalReview(ERCreate model) { var entity = new EthicalReview() { Id = _userId, EthicalOrganizationId = model.EthicalOrganizationId, EthicalReviewTitle = model.EthicalReviewTitle, EthicalReviewText = model.EthicalReviewText }; using (var ctx = new ApplicationDbContext()) { ctx.EthicalReviews.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(ERCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateEthicalReviewService(); if (service.CreateEthicalReview(model)) { TempData["SaveResult"] = "Your review was created."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Review could not be created."); return(View(model)); }