public ExameComp(string exameId, string key, EPeriodoComp periodo = EPeriodoComp.Hora, DateTime?expiraEm = null, string usuarioId = null)
 {
     ExameId   = exameId;
     Key       = key;
     Periodo   = periodo;
     UsuarioId = usuarioId;
     ExpiraEm  = expiraEm ?? DateTime.Now.AddHours(1);
 }
        public IActionResult CompartilharQrCode(string exameId, EPeriodoComp periodo)
        {
            var    key  = _exameService.GerarCodigoComp(exameId, periodo);
            string port = !HttpContext.Request.Host.Port.HasValue ? "" : $":{HttpContext.Request.Host.Port}";
            string http = HttpContext.Request.IsHttps ? "https://" : "http://";
            string host = $"{http}{HttpContext.Request.Host.Host}{port}";
            string path = $"{host}/exame/compartilhado/{key}";

            return(View(new ExameCompViewModel {
                ExameId = exameId, Periodo = periodo, Key = key, Url = path
            }));
        }
Пример #3
0
        public string GerarCodigoComp(string exameId, EPeriodoComp periodo = EPeriodoComp.Hora)
        {
            var exame = _exameRepository.ObterPorId(exameId);

            if (exame == null)
            {
                AdicionarErroModelState("Exame não encontrado", "ExameService");
                return(null);
            }

            ExameComp exameComp = new ExameComp(exameId, Guid.NewGuid().ToString(), periodo, ObterDateTimePorPeriodoComp(periodo));

            _exameCompRepository.Inserir(exameComp);
            _uow.Commit();
            if (ExisteErrosNoModelState())
            {
                return(null);
            }
            return(exameComp.Key);
        }
Пример #4
0
        private DateTime ObterDateTimePorPeriodoComp(EPeriodoComp periodo)
        {
            switch (periodo)
            {
            case EPeriodoComp.Hora:
                return(DateTime.Now.AddHours(1));

            case EPeriodoComp.Dia:
                return(DateTime.Now.AddDays(1));

            case EPeriodoComp.Semana:
                return(DateTime.Now.AddDays(7));

            case EPeriodoComp.Mes:
                return(DateTime.Now.AddMonths(1));

            default:
                return(DateTime.Now.AddHours(1));
            }
        }