public ActionResult <TestAthleteViewModel> GetAthleteListByTestID(long id) { TestAthleteViewModel model = new TestAthleteViewModel(); model = _repo.TestCustomRepository.GetAthleteListByTestID(id); return(Ok(model)); }
public ActionResult CreateAthleteTest(TestAthleteViewModel model) { try { if (ModelState.IsValid) { PayloadResponse response = new PayloadResponse(); using (var repository = new WebApiClientRepository <PayloadResponse>()) { response = repository.GlobalApiCallPost(model, "api/Test/CreateTestAthlete"); if (response != null) { if (response.Success) { TempData["message_data_success"] = response.Message; return(RedirectToAction(nameof(Details), new { id = model.ID })); } else { TempData["message_data"] = response.Message; return(RedirectToAction(nameof(Details), new { id = model.ID })); } } } } // TODO: Add insert logic here TempData["message_data"] = "Problem on Athlete adding"; return(RedirectToAction(nameof(Details), new { id = model.ID })); } catch { return(View()); } }
public IActionResult Details(long?id) { TestAthleteViewModel model = new TestAthleteViewModel(); using (var repository = new WebApiClientRepository <TestAthleteViewModel>()) { var payload = repository.GlobalApiCallGet(null, "api/Test/GetAthleteListByTestID?id=" + id); if (payload != null) { model = payload; } } ViewBag.AthleteID = new SelectList(GetAthlete(), "ID", "Name"); return(View(model)); }
public ActionResult <PayloadResponse> CreateTestAthlete([FromBody] TestAthleteViewModel info) { PayloadResponse response = new PayloadResponse(); TestAthlete testAthlete = new TestAthlete(); if (info == null) { response.Message = "Data did not send properly"; response.Payload = testAthlete; response.PayloadType = "CreateTestAthlete"; response.ResponseTime = DateTime.Now.ToString(); response.Success = false; return(response); } TestAthlete existingTest = _repo.TestCustomRepository.GetTestAthleteByTestAndAthlete(info.ID, info.AthleteID); if (existingTest != null && existingTest.ID > 0) { response.Message = string.Format("The Athlete ({0} {1}) is already exist into the Test. ", existingTest.Athlete.FirstName, existingTest.Athlete.LastName); response.Payload = testAthlete; response.PayloadType = "CreateTestAthlete"; response.ResponseTime = DateTime.Now.ToString(); response.Success = false; return(response); } testAthlete.AthleteID = info.AthleteID; testAthlete.TestValue = info.TestValue; testAthlete.TestID = info.ID; testAthlete.CreatedBy = Convert.ToInt32(User.Identity.Name); testAthlete.CreatedDate = DateTime.Now; testAthlete.IsRemoved = false; testAthlete.FitnessRatingID = _repo.TestCustomRepository.GetFitnessRatingID(testAthlete.TestValue); _repo.TestAthleteRepository.Add(testAthlete); _repo.Save(); response.Message = "Athlete is successfully added in Test."; response.Payload = null; response.PayloadType = "CreateTestAthlete"; response.ResponseTime = DateTime.Now.ToString(); response.Success = true; return(response); }