Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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);
        }
Beispiel #4
0
 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"));
 }
Beispiel #5
0
        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);
        }
Beispiel #7
0
        public IActionResult Edit(int id)
        {
            SwimmerDTO swimmer = service.GetSwimmer(id);

            return(View(swimmer));
        }