public async Task <SolicitationDto> Execute(SolicitationDto solicitationDto, int clientId) { if (solicitationDto.AskDtos.Count() < 5) { throw new AppError("Responda todas as questões!"); } if (clientId == 0) { throw new AppError("Escolha um cliente válido!"); } Pessoa client = await _pessoaRepository.GetByID(clientId); if (client == null) { throw new AppError("Cliente não encontrado!", 404); } if (solicitationDto.ReceivingDate > DateTime.Now) { throw new AppError("Data de recebimento não pode ser uma data futura"); } Solicitacao solicitacao = SolicitationDtoMapToSolicitacao.Map(new Solicitacao(), solicitationDto); solicitacao.fkPessoa = client; solicitacao.fkPessoaId = client.Id; _solicitacaoRepository.Insert(solicitacao); await _solicitacaoRepository.Commit(); solicitationDto.Id = solicitacao.Id; return(solicitationDto); }
public async Task <SolicitationDto> Execute(SolicitationDto solicitationDto) { Solicitacao solicitacao = await _solicitacaoRepository.GetByID(solicitationDto.Id); SolicitationDtoMapToSolicitacao.Map(solicitacao, solicitationDto); _solicitacaoRepository.Save(solicitacao); return(solicitationDto); }
public static Solicitacao Map(Solicitacao solicitacao, SolicitationDto solicitationDto) { solicitacao.Id = solicitationDto.Id; solicitacao.fkPessoa = solicitationDto.clientDto != null?ClientDtoMapToPessoa.Map(new Pessoa(), solicitationDto.clientDto) : null; solicitacao.fkPessoaId = solicitationDto.clientDto != null ? solicitationDto.clientDto.Id : null; solicitacao.Observacao = solicitationDto.Observation; solicitacao.Perguntum = new List <Pergunta>(); foreach (var ask in solicitationDto.AskDtos) { solicitacao.Perguntum.Add(AskDtoMapToPergunta.Map(new Pergunta(), ask)); } solicitacao.Julgamento = !solicitacao.Perguntum.Any(x => x.Resposta == false); return(solicitacao); }
public async Task <IActionResult> OnGetAsync() { ResponseDto responseDto = (ResponseDto)((ObjectResult)(await _clientController.List(_selectedClientId))).Value; _clientDtos = (List <ClientDto>)responseDto.detail; _solicitationDto = new SolicitationDto(); _solicitationDto.AskDtos = new List <AskDto>(); _solicitationDto.AskDtos.Add(new AskDto(EnumQuestion.Packaged)); _solicitationDto.AskDtos.Add(new AskDto(EnumQuestion.Proccess)); _solicitationDto.AskDtos.Add(new AskDto(EnumQuestion.Volume)); _solicitationDto.AskDtos.Add(new AskDto(EnumQuestion.Temperature)); _solicitationDto.AskDtos.Add(new AskDto(EnumQuestion.Transport)); return(Page()); }
public static SolicitationDto Map(SolicitationDto solicitationDto, Solicitacao solicitacao) { solicitationDto.Id = solicitacao.Id; solicitationDto.clientDto = solicitationDto.clientDto ?? new ClientDto(); solicitationDto.clientDto.Id = solicitacao.fkPessoaId ?? 0; solicitationDto.Observation = solicitacao.Observacao; solicitationDto.CompletionDate = solicitacao.DataConclusao ?? new DateTime(); solicitationDto.ReceivingDate = solicitacao.DataRecebimento ?? new DateTime(); solicitationDto.AskDtos = new List <AskDto>(); foreach (var pergunta in solicitacao.Perguntum) { solicitationDto.AskDtos.Add(PerguntaMapToAskDto.Map(new AskDto(), pergunta)); } return(solicitationDto); }
public SampleDto() { Client = new ClientDto(); Solicitation = new SolicitationDto(); Assays = new List <AssayDto>(); }
public async Task <IActionResult> Update([FromBody] SolicitationDto solicitationDto) { solicitationDto = await _updateSolicitationService.Execute(solicitationDto); return(Ok(new ResponseDto("success", solicitationDto))); }
public async Task <IActionResult> Create([FromBody] SolicitationDto solicitationDto, int clientId) { solicitationDto = await _createSolicitationService.Execute(solicitationDto, clientId); return(Ok(new ResponseDto("success", solicitationDto))); }