public ActionResult Create(PairingCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreatePairingService(); if (service.CreatePairing(model)) { TempData["SaveResult"] = "Pairing information has been entered sucessfully."; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Pairing information was not saved."); return(View(model)); }
public bool CreatePairing(PairingCreate model) { var pairingEntity = new Pairing() { OwnerID = _userID, MaleGeckoID = model.MaleGeckoID, MaleGeckoName = model.MaleGeckoName, FemaleGeckoID = model.FemaleGeckoID, FemaleGeckoName = model.FemaleGeckoName, Season = model.Season }; using (var ctx = new ApplicationDbContext()) { ctx.Pairings.Add(pairingEntity); return(ctx.SaveChanges() == 1); } }