public ViewResult Edit(Blog b, int blogid)
        {
            string      name    = HttpContext.Session.GetString("Name");
            int         id      = PublicUserRepo.GetId(name);
            List <Blog> myBlogs = BlogRepo.getMyBlogs(id);

            if (ModelState.IsValid)
            {
                foreach (Blog bl in myBlogs)
                {
                    if (bl.blog_Id == b.blog_Id)
                    {
                        bl.Title   = b.Title;
                        bl.Content = b.Content;
                        bl.Date    = b.Date;
                        BlogRepo.RemoveBlog(bl.blog_Id);
                        BlogRepo.AddBlog(b, id); //Sath hi database ma b update kr dia h
                        break;
                    }
                }

                return(View("ViewMyBlogs", myBlogs));
            }
            else
            {
                ModelState.AddModelError(String.Empty, "Please enter correct data");
                return(View());
            }
        }
        public ViewResult ViewMyBlogs()
        {
            string      name  = HttpContext.Session.GetString("Name");
            int         id    = PublicUserRepo.GetId(name);
            List <Blog> blogs = BlogRepo.getMyBlogs(id);

            return(View(blogs));
        }
        public ViewResult Profile()
        {
            string  name = HttpContext.Session.GetString("Name");
            int     id   = PublicUserRepo.GetId(name);
            Profile pro  = ProfileRepo.GetProfile(id);

            return(View("Profile", pro));
        }
        public ViewResult HomePage(int myid, Blog b)
        {
            string     name = HttpContext.Session.GetString("Name");
            int        id   = PublicUserRepo.GetId(name);
            PublicUser usr  = PublicUserRepo.getUserbyId(id);

            return(View(usr));
        }
        public ViewResult Remove(int id)
        {
            BlogRepo.RemoveBlog(id);
            string      name  = HttpContext.Session.GetString("Name");
            int         myid  = PublicUserRepo.GetId(name);
            List <Blog> blogs = BlogRepo.getMyBlogs(myid);

            return(View("ViewMyBlogs", blogs));
        }
 public ViewResult CreateBlog(string nam, Blog b)
 {
     b.Date = DateTime.Today.ToString();
     if (ModelState.IsValid)
     {
         string name = HttpContext.Session.GetString("Name");
         int    id   = PublicUserRepo.GetId(name);
         BlogRepo.AddBlog(b, id);
         PublicUser usr = PublicUserRepo.getUserbyId(id);
         return(View("HomePage", usr));
     }
     else
     {
         ModelState.AddModelError(String.Empty, "Please enter correct data");
         return(View());
     }
 }
        public IActionResult Profile(Profile pro)
        {
            if (ModelState.IsValid)
            {
                string name = HttpContext.Session.GetString("Name");
                int    id   = PublicUserRepo.GetId(name);
                ProfileRepo.DeleteProfile(id);
                ProfileRepo.UpdateProfile(id, pro);
                HttpContext.Session.SetString("Name", pro.Usrinfo.Name); //Incase if user changes the name

                return(View("HomePage", pro.Usrinfo));
            }
            else
            {
                ModelState.AddModelError(String.Empty, "Please enter correct data");
                return(View("Profile", pro));
            }
        }