public PersistedState Edit(NotaDTO dto)
        {
            Nota       nota = FindById(dto.NotaId);
            AES_Result res  = CryptoService.AES_Encrypt(dto.NoteContent);

            nota.NoteContent = res.CipherData;
            nota.Nonce       = res.Nonce;
            nota.LUDT        = DateTime.Now;
            PersistedState ps = _notasRepo.TrySaveChanges();

            _notasRepo.Dispose();
            return(ps);
        }
Example #2
0
        public void ProcessEmailVerification(string userId, string email, string alias, string route = "Account/ConfirmEmail", string message = "Para confirmar la cuenta")
        {
            string[]     routeParts    = route.Split('/');
            var          infoToEncript = string.Format("{0}{1}{2}", userId, Resources.KeyCacheSeparator, DateTime.Now.AddMinutes(CodesExpirationInterval).ToString());
            AES_Result   code          = CryptoService.AES_Encrypt(infoToEncript);
            var          callbackUrl   = Url.Action(routeParts[1], routeParts[0], new { userId, code = string.Format("{0}{1}{2}", code.CipherData, Resources.KeyCacheSeparator, code.Nonce) }, protocol: Request.Url.Scheme);
            EmailService es            = new EmailService();

            Task.Run(() => es.SendAsync(new IdentityMessage()
            {
                Destination = string.Format("{0}{1}{2}", email, Resources.KeyCacheSeparator, alias), Subject = "Confirmar cuenta", Body = string.Format("{0}{1}{2}{3}", message, ", haga clic <a href=\"", callbackUrl, "\">aquĆ­</a>")
            }));
        }
        public static Nota ConvertToNota(CreateNotaDTO dto, ApplicationUser user)
        {
            AES_Result res = CryptoService.AES_Encrypt(dto.NoteContent);

            return(new Nota()
            {
                LUDT = DateTime.Now,
                CDT = DateTime.Now,
                NoteContent = res.CipherData,
                Nonce = res.Nonce,
                Anchor = dto.Anchor,
                User = user
            });
        }