public async Task <JsonResult> PostGenerateIcc(GenerateIccInputModel generateIccInputModel)
        {
            var infectionConfirmationCodeEntity =
                await _IccService.GenerateIcc(generateIccInputModel.UserId, null !);

            _DbContext.SaveAndCommit();
            return(new JsonResult(new
            {
                ok = true,
                status = 200,
                icc = infectionConfirmationCodeEntity,
                length = _Configuration.GetSection("IccConfig:Code:Length").Value
            }));
        }
예제 #2
0
        public async Task <ActionResult <object> > PostRedeemIcc(ConfirmLabConfirmationIdModel confirmLabConfirmationIdModel)
        {
            // Make Icc Used, so it can only be used once
            var infectionConfirmationCodeEntity = await _IccService.RedeemIcc(User.Identity.Name);

            _DbContext.SaveAndCommit();

            // POST /labresult call on App Backend
            bool isValid = false;

            try
            {
                isValid = await _AppBackendService.LabConfirmationIdIsValid(confirmLabConfirmationIdModel);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
            if (isValid)
            {
                return(new JsonResult(new
                {
                    ok = true,
                    status = 200
                }));
            }

            return(BadRequest(new
                              { ok = false, status = "400", message = "Invalid LabConfirmationId", payload = confirmLabConfirmationIdModel }));
        }
        public async Task <IActionResult> PostRevokeBatch([FromBody] RevokeBatchInput revokeBatchInput)
        {
            var infectionConfirmationCodeEntity = await _IccService.RedeemIcc(User.Identity.Name);

            bool result = await _IccService.RevokeBatch(revokeBatchInput);

            _DbContext.SaveAndCommit();

            if (result)
            {
                return(new OkResult());
            }
            return(NotFound(new
            {
                ok = false,
                status = 404,
                message = "Batch not found."
            }));
        }