public async Task <IActionResult> Execute()
        {
            _Logger.WriteStart();
            try
            {
                var entity = await _Writer.Execute();

                var result = new EnrollmentResponse
                {
                    ConfirmationKey   = Convert.ToBase64String(entity.ConfirmationKey),
                    BucketId          = Convert.ToBase64String(entity.BucketId),
                    LabConfirmationId = _LabConfirmationIdFormatter.Format(entity.LabConfirmationId), //Architects choice to use UI format in response.
                    Validity          = _WorkflowTime.TimeToLiveSeconds(_UtcDateTimeProvider.Snapshot, entity.ValidUntil)
                };

                return(new OkObjectResult(result));
            }
            catch (Exception ex)
            {
                _Logger.WriteFailed(ex);
                return(new OkObjectResult(new EnrollmentResponse {
                    Validity = -1
                }));
            }
            finally
            {
                _Logger.WriteFinished();
            }
        }
        public async Task <IActionResult> Execute()
        {
            try
            {
                var entity = await _Writer.Execute();

                var result = new EnrollmentResponse
                {
                    ConfirmationKey = Convert.ToBase64String(entity.ConfirmationKey),
                    BucketId        = Convert.ToBase64String(entity.BucketId),
                    //TODO remove formatting when spec is clarified to remove UI concern from data.
                    LabConfirmationId = _LabConfirmationIdFormatter.Format(entity.LabConfirmationId),
                    Validity          = _WorkflowTime.TimeToLiveSeconds(_UtcDateTimeProvider.Snapshot, entity.ValidUntil)
                };

                return(new OkObjectResult(result));
            }
            catch (Exception ex)
            {
                //TODO: check if you want to use Serilog's Exception logging, or just use ToString
                _Logger.LogError(ex.ToString());
                return(new OkObjectResult(new EnrollmentResponse {
                    Validity = -1
                }));
            }
        }
        public async Task <IActionResult> Execute()
        {
            try
            {
                var result = await _Writer.Execute();

                return(new OkObjectResult(result));
            }
            catch (Exception e)
            {
                _Logger.LogError(e.ToString());
                //TODO positive indication of an error to clients? Empty response? Or just 500?
                return(new OkObjectResult(new EnrollmentResponse {
                    Validity = -1
                }));
            }
        }
Exemple #4
0
        public async Task <IActionResult> Execute()
        {
            var result = await _Writer.Execute();

            return(new OkObjectResult(result));
        }