Пример #1
0
        public Task <HttpResponseMessage> Post([FromBody] dynamic body)
        {
            var validate = _serviceSession.GetAllByCoachingProcess(Guid.Parse((string)body.coachingProcess.id));

            foreach (var item in  validate)
            {
                if (item.StartTime == (TimeSpan)body.startTime && item.Date == (DateTime)body.date)
                {
                    return(CreateResponse(HttpStatusCode.BadRequest, null));
                }
            }

            var listJob         = _serviceJob.AddJobToSession(body.job);
            var coachingProcess = _serviceCoachingProcess.GetOne(Guid.Parse((string)body.coachingProcess.id));
            var user            = _serviceUser.GetOne((string)body.idUser);
            var commandSession  = new CreateSessionCommand(
                coachingProcess,
                (string)body.theme,
                user,
                (DateTime)body.date,
                (TimeSpan)body.startTime,
                (TimeSpan)body.endTime,
                (ESessionClassification)body.classification,
                (string)body.observation,
                listJob
                );

            var session = _serviceSession.Create(commandSession);

            _serviceEvaluationCoach.AddToSession(body.coach, session.Id);
            _serviceEvaluationCoachee.AddToSession(body.coachee, session.Id);

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