public FilledToolCoach Create(CreateFilledToolCoachCommand command) { var service = new FilledToolCoach(command.EvaluationDate, command.IdEvaluationTool, command.idCoachingProcess, command.IdCoach); service.Validate(); _repository.Create(service); if (Commit()) return service; return null; }
public Task<HttpResponseMessage> FilledToll([FromBody]dynamic body) { var role = (string)body.role; var evaluationToolOrigin = _serviceEvaluationTool.GetOne(Guid.Parse((string)body.idEvaluationTool)); List<Question> listQuestion = new List<Question>(); foreach (var question in evaluationToolOrigin.Question) { List<Reply> listReply = new List<Reply>(); foreach (var reply in question.Reply) listReply.Add(new Reply(reply.BodyReply, reply.Group)); listQuestion.Add(new Question(question.TypeReply, question.TypeQuestion, question.StepQuestion, question.Enunciation, question.Education, listReply, question.PhaseQuestion, question.Group)); } var newEvaluationToolFilled = _serviceEvaluationTool.Create(new CreateEvaluationToolCommand( evaluationToolOrigin.Name, evaluationToolOrigin.Type, listQuestion, evaluationToolOrigin.Coach, evaluationToolOrigin.Author )); if (role == "Coachee") { var commandFilledTool = new CreateFilledToolCoacheeCommand( DateTime.MinValue, newEvaluationToolFilled.Id, Guid.Parse((string)body.idCoachingProcess), Guid.Parse((string)body.idUser) ); var filledTool = _serviceFilledToolCoachee.Create(commandFilledTool); return CreateResponse(HttpStatusCode.Created, filledTool); } else if (role == "Coach") { var commandFilledTool = new CreateFilledToolCoachCommand( DateTime.MinValue, Guid.Parse((string)body.idEvaluationTool), Guid.Parse((string)body.idCoachingProcess), Guid.Parse((string)body.idUser) ); var filledTool = _serviceFilledToolCoach.Create(commandFilledTool); return CreateResponse(HttpStatusCode.Created, filledTool); } return CreateResponse(HttpStatusCode.BadRequest, null); }