public IActionResult updateAthelete(TestSubscriptionVM testSubscription) { TestSubscription data = db.TestSubscriptions.Where(s => s.TestSubscriptionID == testSubscription.TestSubscriptionID).FirstOrDefault(); data.AthleteId = testSubscription.AtheleteId; data.Distance = testSubscription.Distance; db.SaveChanges(); return(RedirectToAction("Details", new { id = testSubscription.TestID })); }
public IActionResult DeleteAtheleteTest(int id, TestSubscriptionVM testSubscription) { TestSubscription test = db.Set <TestSubscription>().SingleOrDefault(c => c.TestSubscriptionID == testSubscription.TestSubscriptionID); if (test != null) { db.Entry(test).State = Microsoft.EntityFrameworkCore.EntityState.Deleted; db.SaveChanges(); } return(RedirectToAction("Details", new { id = testSubscription.TestID })); }
public IActionResult AddAthelete(int id) { ViewBag.ListOfAthletes = db.Athletes.Where(x => x.RoleId == 1).ToList().Select(x => new { Ranking = x.AthleteName, AtheleteId = x.AthleteId }); TestSubscriptionVM testSubscription = new TestSubscriptionVM(); testSubscription.TestID = id; return(View(testSubscription)); }
public ActionResult editAthelete(int id) { ViewBag.ListOfAthletes = db.Athletes.Where(x => x.RoleId == 1).ToList().Select(x => new { Ranking = x.AthleteName, AtheleteId = x.AthleteId }); TestSubscriptionVM testSubscription = db.TestSubscriptions.Where(x => x.TestSubscriptionID == Convert.ToInt32(id)).Select(x => new TestSubscriptionVM() { TestSubscriptionID = x.TestSubscriptionID, AtheleteId = x.Athletes.AthleteId, Distance = x.Distance, Ranking = x.Athletes.AthleteName, }).FirstOrDefault(); return(PartialView("editAthelete", testSubscription)); }
public IActionResult AddNewAthelete(TestSubscriptionVM testSubscription) { if (ModelState.IsValid) { TestSubscription Subscription = new TestSubscription { Distance = testSubscription.Distance, AthleteId = testSubscription.AtheleteId, TestID = testSubscription.TestID }; db.Add(Subscription); db.SaveChanges(); if (Subscription.TestID > 0) { return(RedirectToAction("Details", new { id = Subscription.TestID })); } } ViewBag.ListOfTests = db.TestTypes.ToList(); ModelState.AddModelError("", "some thing went wrong"); return(View()); }