Example #1
0
 private void UpdateCoach(Coach coach, UpdateCoachCommand command)
 {
     coach.FirstName = command.CoachFirstName;
     coach.LastName  = command.CoachLastName;
     coach.Age       = command.CoachAge;
     coach.Email     = command.CoachEmail;
     coach.Phone     = command.CoachPhone;
 }
Example #2
0
        public async Task <IActionResult> UpdateCoach(int id, [FromBody] UpdateCoachCommand item)
        {
            var coach = await _coachRepository.GetByIdAsync(id);

            coach.Update(item.Name, item.Email);
            await _coachRepository.CommitAsync();

            return(Ok());
        }
Example #3
0
        public async Task <IActionResult> Update(int id, UpdateCoachCommand command)
        {
            if (id != command.Id)
            {
                return(BadRequest());
            }

            await Mediator.Send(command);

            return(Ok());
        }
Example #4
0
        public void Handle(UpdateCoachCommand command)
        {
            // TODO validate

            using (var dbContext = new ManagementDataContext())
            {
                Team team = dbContext.Teams.SingleOrDefault(l => l.Id == command.TeamId);

                if (team == null || team.Coach == null)
                {
                    throw new ServerSideException("Ups, something went wrong! Refresh page and try agine");
                }

                UpdateCoach(team.Coach, command);
                dbContext.SaveChanges();
            }
        }
        public Coach Update(UpdateCoachCommand commandCoach)
        {
            Coach coach = _repository.GetOneIncludeDetails(commandCoach.Id);

            foreach (var speciality in commandCoach.Speciality)
            {
                coach.AddSpeciality(speciality);
            }
            foreach (var formation in commandCoach.Formation)
            {
                coach.AddFormation(formation);
            }
            _repository.Update(coach);

            if (Commit())
            {
                return(coach);
            }

            return(null);
        }
        public ActionResult UpdateCoach(UpdateCoachCommand command)
        {
            HandleCommand(command, Json("Team created"));

            return(RedirectToAction("Index"));
        }