public void UpdateSwimmer(SwimmerDTO swimmer) { Swimmer updatedSwimmer = new Swimmer { FirstName = swimmer.FirstName, LastName = swimmer.LastName, Age = Convert.ToInt32(swimmer.Age), CoachId = Convert.ToInt32(swimmer.CoachId) }; _swimmerManager.Update(Convert.ToInt32(swimmer.Id), updatedSwimmer); }
public void AddSwimmer(SwimmerDTO swimmer) { Swimmer newSwimmer = new Swimmer { FirstName = swimmer.FirstName, LastName = swimmer.LastName, Age = Convert.ToInt32(swimmer.Age), CoachId = Convert.ToInt32(swimmer.CoachId) }; _swimmerManager.Add(newSwimmer); }
public SwimmerDTO GetSwimmer(int id) { var swimmer = _swimmerManager.GetSwimmer(id); SwimmerDTO selectedSwimmer = new SwimmerDTO { Id = swimmer.Id, FirstName = swimmer.FirstName, LastName = swimmer.LastName, Age = Convert.ToInt32(swimmer.Age), CoachId = Convert.ToInt32(swimmer.CoachId) }; return(selectedSwimmer); }
public IActionResult Edit(SwimmerDTO swimmer) { try { service.UpdateSwimmer(swimmer); } catch { return(Content($"\tERROR!\n\n\n Entered data is invalid! Can't edit {swimmer.FirstName} {swimmer.LastName} \n")); } return(RedirectToAction("Index")); }
public IActionResult Update(SwimmerDTO swimmer) { try { service.UpdateSwimmer(swimmer); } catch { return(Content($"\tERROR!\n\n\n Entered data is invalid!")); } return(RedirectToAction("Index")); }
public void SwimmerController_Verify_AddingCalledOnce() { //arrange SwimmerDTO swimmer = new SwimmerDTO() { FirstName = "new", LastName = "swimmer", Age = 11, CoachId = 1 }; var serviceMock = new Mock <ISwimmerService>(); serviceMock.Setup(a => a.AddSwimmer(swimmer)); SwimmerController controller = new SwimmerController(serviceMock.Object); var result = controller.Create(swimmer); serviceMock.Verify(m => m.AddSwimmer(swimmer), Times.Once); }
public IActionResult Edit(int id) { SwimmerDTO swimmer = service.GetSwimmer(id); return(View(swimmer)); }