コード例 #1
0
        public Task <HttpResponseMessage> Put([FromBody] dynamic body)
        {
            var listCoach   = _serviceCoach.AddCoach(body.coach);
            var listCoachee = _serviceCoachee.AddCoachee(body.coachee);
            var listPerformanceIndicator = _servicePerformanceIndicator.AddToCoachingProcess(body.performanceIndicator);
            var listService = _service.AddToCoachingProcess(body.service);


            if (body.endDate == null || body.endDate == "")
            {
                body.endDate = DateTime.MinValue;
            }

            var coachingProcess = _serviceCoachingProcess.GetOneIncludeDetails(Guid.Parse((string)body.id));

            coachingProcess = _serviceCoach.CheckCoachRemovedOfCoachingProcess(listCoach, coachingProcess);
            coachingProcess = _serviceCoachee.CheckCoacheeRemovedOfCoachingProcess(listCoachee, coachingProcess);
            coachingProcess = _service.CheckServiceRemoved(listService, coachingProcess);

            var commandCoachingProcess = new UpdateCoachingProcessCommand(
                id: Guid.Parse((string)body.id),
                name: (string)body.name,
                startDate: (DateTime)body.startDate,
                endDate: (DateTime)body.endDate,
                mode: (EModeProcess)body.mode,
                coach: coachingProcess.Coach,
                coachee: coachingProcess.Coachee,
                performanceIndicator: listPerformanceIndicator,
                service: coachingProcess.Service,
                observation: (string)body.observation
                );

            _servicePerformanceIndicator.CheckPerformanceIndicatorRemoved(listPerformanceIndicator, coachingProcess.Id);
            coachingProcess = _serviceCoachingProcess.Update(commandCoachingProcess);

            return(CreateResponse(HttpStatusCode.Created, coachingProcess));
        }