Esempio n. 1
0
        public ActionResult OnPostSave(int?id)
        {
            if (ModelState.IsValid == false)
            {
                return(Page());
            }

            try
            {
                if (id == null || id == 0)
                {
                    _blogContext.UserInformation.Add(UserInfo);
                    _blogContext.SaveChanges();
                }
                else
                {
                    UserInfo.Id = (int)id;
                    _blogContext.UserInformation.Update(UserInfo);
                    _blogContext.SaveChanges();
                }
            }catch (Exception)
            {
                return(NotFound());
            }

            return(RedirectToPage("/Admin/About"));
        }
Esempio n. 2
0
        public ActionResult OnPostSave(int?id)
        {
            var currentDateTime = DateTime.Now;

            if (id == null || id == 0)
            {
                BlogDetail.CreateTime = currentDateTime;
                BlogDetail.ModifyTime = currentDateTime;
            }
            else
            {
                BlogDetail.ModifyTime = currentDateTime;
            }

            var text = BlogDetail.BlogText;

            try
            {
                if (id == null || id == 0)
                {
                    _blogContext.Blog.Add(BlogDetail);
                    _blogContext.SaveChanges();
                }
                else
                {
                    BlogDetail.Id = (int)id;
                    _blogContext.Blog.Update(BlogDetail);
                    _blogContext.SaveChanges();
                }
            }catch (Exception)
            {
                return(NotFound());
            }

            return(RedirectToPage("/Admin/Blog"));
        }
Esempio n. 3
0
        public ActionResult OnPost(int?id)
        {
            try{
                BlogDetail             = _blogContext.Blog.Find(id);
                BlogComment.Blog       = BlogDetail;
                BlogComment.CreateTime = DateTime.Now;
                BlogDetail.Comment.Add(BlogComment);
                _blogContext.SaveChanges();
            }catch (Exception)
            {
                return(NotFound());
            }

            return(RedirectToPage("/Blog", new { id = BlogDetail.Id }));
        }
Esempio n. 4
0
        public ActionResult OnPost()
        {
            if (ModelState.IsValid == false)
            {
                return(Page());
            }

            try
            {
                _blogContext.Contact.Add(ContactInfo);
                _blogContext.SaveChanges();
            }catch (Exception)
            {
                return(NotFound());
            }

            return(RedirectToPage("/Index"));
        }
Esempio n. 5
0
        public ActionResult OnPost(int id)
        {
            SetPageTitle();
            var newUserName             = Request.Form["userName"];
            var currentPassword         = Request.Form["oldPassword"];
            var newPassword             = Request.Form["newPassword"];
            var newConfirmationPassword = Request.Form["newConfirmationPassword"];
            var adminUser = _blogContext.BlogUser.Find(id);

            byte[] passwordHash;
            byte[] passwordSalt;

            if (newPassword != newConfirmationPassword)
            {
                Message = "new password is not same";
                return(Page());
            }


            if (_SecurityManager.VerifyPassword(currentPassword,
                                                Convert.FromBase64String(adminUser.Password),
                                                Convert.FromBase64String(adminUser.PasswordSalt)) == true)
            {
                _SecurityManager.CreatePasswordHash(newPassword, out passwordHash, out passwordSalt);
                adminUser.Username     = newUserName;
                adminUser.Password     = Convert.ToBase64String(passwordHash);
                adminUser.PasswordSalt = Convert.ToBase64String(passwordSalt);
                try{
                    _blogContext.BlogUser.Update(adminUser);
                    _blogContext.SaveChanges();
                }catch (Exception)
                {
                    return(NotFound());
                }
            }
            else
            {
                Message = "please enter correctly current password";
                return(Page());
            }


            return(RedirectToPage("/Admin/User"));
        }
Esempio n. 6
0
        public ActionResult OnPost()
        {
            var userEmail          = Request.Form["userEmail"];
            var password           = Request.Form["password"];
            var authenticationUser = FindBlogUser(userEmail);

            if (AuthenticateUser(authenticationUser, password) == false)
            {
                Message = "Invalid User name or password";
                return(Page());
            }
            else
            {
                try{
                    authenticationUser.LastLogin = DateTime.Now;
                    _blogContext.BlogUser.Update(authenticationUser);
                    _blogContext.SaveChanges();
                }catch (Exception)
                {
                    return(NotFound());
                }
                return(RedirectToPage("/Admin/About"));
            }
        }