public async Task <ActionResult> Add(InterviewDTO interviewDTO) { interviewDTO.SalesPerson = await _salesPersonService.GetByNameAndEmailAsync(interviewDTO.SalesPerson); var company = await _companyService.GetByNameAsync(interviewDTO.Company.Name); if (company == null) { company = await _companyService.AddAsync(interviewDTO.Company, true); } interviewDTO.Company = company; var interviewer = await _interviewerService.GetByNameAndEmailAsync(interviewDTO.Interviewer); if (interviewer == null) { interviewDTO.Interviewer.Company = company; interviewer = await _interviewerService.AddAsync(interviewDTO.Interviewer); } interviewDTO.Interviewer = interviewer; var interview = await _interviewService.AddAsync(interviewDTO); foreach (var fairId in interviewDTO.FairIds) { await _interviewFairService.AddAsync(new InterviewFairDTO { Name = "GörüşmeKaydıFuar" + fairId, Interview = interview, Company = interviewDTO.Company, Fair = _fairService.Get(Guid.Parse(fairId)) }); } return(Ok()); }
// // Summary: // /// Method responsible for initializing the schema. /// // // Parameters: // interviewService: // The interviewService param. // public InterviewMutationType(IInterviewService interviewService) { Name = "InterviewMutation"; Description = "Interview Mutation Type"; FieldAsync <InterviewType>( name: "createInterview", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <InterviewInputType> > { Name = "data" } ), resolve: async context => { InterviewCommand data = context.GetArgument <InterviewCommand>("data"); Interview result = await interviewService.AddAsync(data); if (interviewService.ValidationResult().IsValid is true) { return(result); } context.Errors.AddRange(interviewService.ValidationResult().Errors.Select(x => new ExecutionError(x.ErrorMessage))); return(null); } ); FieldAsync <BooleanGraphType>( name: "removeInterview", arguments: new QueryArguments( new QueryArgument <NonNullGraphType <IdGraphType> > { Name = "id" } ), resolve: async context => { Guid id = context.GetArgument <Guid>("id"); await interviewService.RemoveAsync(id); if (interviewService.ValidationResult().IsValid is true) { return(true); } context.Errors.AddRange(interviewService.ValidationResult().Errors.Select(x => new ExecutionError(x.ErrorMessage))); return(null); } ); }
public async Task <IActionResult> Create([FromBody] InterviewCommand command) { if (command is null) { return(BadRequest()); } Interview interview = await _interviewService.AddAsync(command); if (interview is null) { return(BadRequest(_interviewService.ValidationResult() .Errors .Select(x => new ValidationResult() { PropertyName = x.PropertyName, ErrorMessage = x.ErrorMessage }))); } return(Ok(_mapper.Map <Interview, InterviewResult>(interview))); }