public Session Update(UpdateSessionCommand command) { var session = _repositorySession.GetOne(command.Id); if (command.Classification != 0) session.ChangeClassification(command.Classification); if (command.Date != DateTime.MinValue) session.ChangeDate(command.Date); if (command.EndTime != TimeSpan.MinValue) session.ChangeEndTime(command.EndTime); if (command.StartTime != TimeSpan.MinValue) session.ChangeStartTime(command.StartTime); if (command.Theme!= null) session.ChangeTheme(command.Theme); if (command.CoachingProcess != null) session.ChangeCoachingProcess(command.CoachingProcess); if (!string.IsNullOrEmpty(command.Observation)) session.ChangeObservation(command.Observation); if (command.Coach != null) { foreach (var coach in command.Coach) { session.AddEvaluationCoach(coach); } } if (command.Coachee != null) { foreach (var coachee in command.Coachee) { session.AddEvaluationCoachee(coachee); } } if (command.Job != null) { foreach (var job in command.Job) { session.AddJob(job); } } _repositorySession.Update(session); if (Commit()) return session; return null; }
public Task<HttpResponseMessage> Put([FromBody]dynamic body) { List<Job> listJob = _serviceJob.AddJobToSession(body.job); var user = _serviceUser.GetOne((string)body.idUser); var coachingProcess = _serviceCoachingProcess.GetOne(Guid.Parse((string)body.idCoachingProcess)); var session = _serviceSession.GetOne(Guid.Parse((string)body.id)); session = _serviceJob.CheckJobRemovedOfSession(listJob, session); var commandSession = new UpdateSessionCommand( Guid.Parse((string)body.id), coachingProcess, (string)body.theme, user, (DateTime)body.date, (TimeSpan)body.startTime, (TimeSpan)body.endTime, (ESessionClassification)body.classification, (string)body.observation, session.Job, session.EvaluationCoach, session.EvaluationCoachee ); session = _serviceSession.Update(commandSession); var listEvaluationCoach = _serviceEvaluationCoach.AddToSession(body.coach, session.Id); _serviceEvaluationCoach.CheckEvaluationCoachRemoved(listEvaluationCoach, session.Id); var listEvaluationCoachee = _serviceEvaluationCoachee.AddToSession(body.coachee, session.Id); _serviceEvaluationCoachee.CheckEvaluationCoacheeRemoved(listEvaluationCoachee, session.Id); return CreateResponse(HttpStatusCode.Created, session); }