コード例 #1
0
 public ActionResult Edit([Bind(Include = "TrainerId,FirstName,LastName,Salary,PhoneNumber,Email,PhotoUrl")] Trainer trainer, IEnumerable <int> SelectedCoursesId)
 {
     if (ModelState.IsValid)
     {
         repos.Update(trainer, SelectedCoursesId);
         return(RedirectToAction("Index"));
     }
     return(View(trainer));
 }
 public ActionResult Edit([Bind(Include = "TrainerId,FirstName,LastName,Subject")] Trainer trainer, IEnumerable <int> SelectedCoursesId)
 {
     if (ModelState.IsValid)
     {
         trainerRepository.Update(trainer, SelectedCoursesId);
         return(RedirectToAction("TrainerInfo"));
     }
     return(View(trainer));
 }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "TrainerId,FirstName,LastName,DateOfBirth,Salary,PhotoUrl,Telephone,Email,Country")] Trainer trainer, IEnumerable <int> selectedCourseId)
 {
     if (ModelState.IsValid)
     {
         trainerRepository.Update(trainer, selectedCourseId);
         return(RedirectToAction("TrainerTable"));
     }
     return(View(trainer));
 }
コード例 #4
0
        public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, int id)
        {
            var repo           = new TrainerRepository();
            var updatedTrainer = new Trainer
            {
                Name = updatedTrainerCommand.Name,
                YearsOfExperience = updatedTrainerCommand.YearsOfExperience,
                Specialty         = updatedTrainerCommand.Specialty,
            };
            var trainer = repo.Update(updatedTrainer, id);

            return(Ok(trainer));
        }
コード例 #5
0
        public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, Guid id)
        {
            //mapping/transforming
            var repo = new TrainerRepository();

            var updatedTrainer = new Trainer
            {
                Name       = updatedTrainerCommand.Name,
                YearsOfExp = updatedTrainerCommand.YearsOfExp,
                Specialty  = updatedTrainerCommand.Specialty,
            };

            var trainerThatGotUpdated = repo.Update(updatedTrainer, id);

            return(Ok(trainerThatGotUpdated));
        }
コード例 #6
0
        public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, int id)
        {
            var updatedTrainer = new Trainer
            {
                Name = updatedTrainerCommand.Name,
                YearsOfExperience = updatedTrainerCommand.YearsOfExperience,
                Specialty         = updatedTrainerCommand.Specialty
            };

            var trainerThatGotUpdated = _repo.Update(updatedTrainer, id);

            if (trainerThatGotUpdated == null)
            {
                return(NotFound("Could not update trainer"));
            }

            return(Ok(trainerThatGotUpdated));
        }
コード例 #7
0
        public IActionResult UpdateTrainer(UpdateTrainerCommand updatedTrainerCommand, int id)
        {
            var repo = new TrainerRepository();

            var updatedTrainer = new Trainer
            {
                Name             = updatedTrainerCommand.Name,
                YearOfExperience = updatedTrainerCommand.YearOfExperience,
                Specialty        = updatedTrainerCommand.Specialty,
            };

            var updatedRepoTrainer = repo.Update(updatedTrainer, id);

            if (updatedRepoTrainer == null)
            {
                return(NotFound("Could not update trainer"));
            }

            return(Ok(updatedRepoTrainer));
        }
コード例 #8
0
        public static void UpdateTrainer(Trainer t)
        {
            TrainerRepository trainerRepository = new TrainerRepository();

            trainerRepository.Update(t);
        }
コード例 #9
0
        public bool Update(Trainer trainer)
        {
            bool isSaved = _trainerRepository.Update(trainer);

            return(isSaved);
        }