public Ticket TicketTorg(string thumbprint, string fileName) { CreateAnswerResponse response = null; try { string uuid = fileName.Split('_')[5].Replace(".xml", ""); ExCert cert = GetExCertificate(thumbprint); ExSigner signer = new ExSigner(cert); CreateAnswerRequest req = new CreateAnswerRequest(authToken, uuid, new AnswerData(signer)); response = (CreateAnswerResponse)Http2.post <CreateAnswerResponse>("https://api-service.edi.su/Api/Dixy/Ticket/Generate", req); if (response.intCode != 200) { Logger.log("for file [" + fileName + "] :" + response.varMessage); return(null); } string name = GetIDFileFromTicket(response.content); byte[] body = Utils.Base64DecodeToBytes(response.content, "windows-1251"); return(new Ticket(name, body)); } catch (Exception ex) { Logger.log("for file [" + fileName + "] :" + response.varMessage); Logger.log(ex.Message); return(null); } }
public async Task <bool> CreateAnswer(CreateAnswerRequest request) { var answer = _mapper.Map <Answers>(request); _context.Answers.Add(answer); await _context.SaveChangesAsync(); return(true); }
public async Task <IActionResult> CreateAnswerAsync([FromBody] CreateAnswerRequest model, CancellationToken token) { var userId = _userManager.GetLongUserId(User); try { var command = new CreateAnswerCommand(model.QuestionId, model.Text, userId); await _commandBus.DispatchAsync(command, token); return(Ok()); } catch (QuotaExceededException) { ModelState.AddModelError(nameof(model.Text), _localizer["You exceed your quota of answers"]); return(BadRequest(ModelState)); } catch (ArgumentException) { ModelState.AddModelError(nameof(model.Text), _localizer["QuestionNotExists"]); return(BadRequest(ModelState)); } }
public ActionResult AddAnswer(CreateAnswerRequest createRequest) { var newAnswer = _answerRepository.AddAnswer(createRequest.AnswerText, createRequest.StudentId, createRequest.QuestionId, createRequest.QuestionText, createRequest.AnswerDate); return(Created($"/api/student/{newAnswer.Id}", newAnswer)); }
public async Task <IActionResult> CreateAnswer([FromBody] CreateAnswerRequest request) { var result = await _answerService.CreateAnswer(request); return(Ok(result)); }