public async Task <IActionResult> Edit(PlantillaConsentimientoInformado plantillaConsentimientoInformado)
        {
            var i = (ClaimsIdentity)User.Identity;

            if (i.IsAuthenticated)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        try
                        {
                            plantillaConsentimientoInformado.Codigo = Encriptacion.Decrypt(plantillaConsentimientoInformado.Codigo);
                            _context.Update(plantillaConsentimientoInformado);
                            await _context.SaveChangesAsync();

                            await _auditoria.GuardarLogAuditoria(Funciones.ObtenerFechaActual("SA Pacific Standard Time"), i.Name, "plantillaConsentimientoInformado", plantillaConsentimientoInformado.Codigo, "U");

                            ViewBag.Message = "Save";

                            return(View(plantillaConsentimientoInformado));
                        }
                        catch (DbUpdateConcurrencyException)
                        {
                            throw;
                        }
                    }

                    return(View(plantillaConsentimientoInformado));
                }
                catch (Exception e)
                {
                    string mensaje = e.Message;
                    if (e.InnerException != null)
                    {
                        mensaje = MensajesError.UniqueKey(e.InnerException.Message);
                    }

                    ViewBag.Message = mensaje;

                    return(View(plantillaConsentimientoInformado));
                }
            }
            else
            {
                return(Redirect("../Identity/Account/Login"));
            }
        }
        public async Task <IActionResult> Create(PlantillaConsentimientoInformado plantillaConsentimientoInformado)
        {
            var i = (ClaimsIdentity)User.Identity;

            if (i.IsAuthenticated)
            {
                try
                {
                    if (ModelState.IsValid)
                    {
                        Int64 maxCodigo = 0;
                        maxCodigo  = Convert.ToInt64(_context.PlantillaConsentimientoInformado.Max(f => f.Codigo));
                        maxCodigo += 1;
                        plantillaConsentimientoInformado.Codigo = maxCodigo.ToString("D4");
                        _context.Add(plantillaConsentimientoInformado);
                        await _context.SaveChangesAsync();

                        await _auditoria.GuardarLogAuditoria(Funciones.ObtenerFechaActual("SA Pacific Standard Time"), i.Name, "plantillaConsentimientoInformado", plantillaConsentimientoInformado.Codigo, "I");

                        ViewBag.Message = "Save";
                        return(View(plantillaConsentimientoInformado));
                    }
                    return(View(plantillaConsentimientoInformado));
                }
                catch (Exception e)
                {
                    string mensaje = e.Message;
                    if (e.InnerException != null)
                    {
                        mensaje = MensajesError.UniqueKey(e.InnerException.Message);
                    }

                    ViewBag.Message = mensaje;

                    return(View(plantillaConsentimientoInformado));
                }
            }
            else
            {
                return(Redirect("../Identity/Account/Login"));
            }
        }