コード例 #1
0
        public ActionResult Index(int?id)
        {
            string current_logged_in_user_id = User.Identity.GetUserId();

            Session["result_password"] = null;
            Session["Id"] = null;
            var result = (from s in db.GetPasswordStorage
                          where s.UserId == current_logged_in_user_id
                          select new
            {
                id = s.Id,
                Password = s.Password,
            }).AsEnumerable().Select(a => new PasswordStorage
            {
                Id       = a.id,
                Password = AdvancedEncryptionStandard.DecryptText(a.Password),
            }).FirstOrDefault();

            if (id > 0)
            {
                var result_password = (from s in db.GetPasswordStorage
                                       where s.Id == id
                                       select new
                {
                    id = s.Id,
                    Password = s.Password,
                }).AsEnumerable().Select(a => new PasswordStorage
                {
                    Id       = a.id,
                    Password = AdvancedEncryptionStandard.DecryptText(a.Password),
                }).FirstOrDefault();
                Session["Id"] = result_password.Id.ToString();
                Session["result_password"] = result_password.Password.ToString();
            }


            Session["Password"] = result.Password.ToString();
            return(View());
        }
コード例 #2
0
        public ActionResult Index()
        {
            // Here we get current logged in users id
            string current_logged_in_user_id = User.Identity.GetUserId();

            // this linq query show all the storage password information for the logged in user only
            var result = (from s in db.GetPasswordStorage
                          where s.UserId == current_logged_in_user_id
                          select new
            {
                id = s.Id,
                Website = s.Website,
                Password = s.Password,
                DateSaved = s.DateSaved
            }).AsEnumerable().Select(a => new PasswordStorage
            {
                Id        = a.id,
                Website   = a.Website,
                Password  = AdvancedEncryptionStandard.DecryptText(a.Password),
                DateSaved = a.DateSaved
            }).ToList();

            return(View(result));
        }