public async Task <IActionResult> Create([Bind(include: "Title, Description, Date, Photo")] OurBlog ourBlog)
        {
            if (!ModelState.IsValid)
            {
                return(View(ourBlog));
            }

            if (ourBlog.Photo == null)
            {
                ModelState.AddModelError("Photo", "Photo can't be null...");
                return(View(ourBlog));
            }

            if (!ourBlog.Photo.isImage())
            {
                ModelState.AddModelError("Photo", "Photo type is not valid...");
                return(View(ourBlog));
            }

            ourBlog.Image = await ourBlog.Photo.SaveAsync(_env.WebRootPath, "images", "asbabphotos");

            ourBlog.Date = DateTime.Now.ToString("MMMM dd,  yyyy");
            _context.OurBlogs.Add(ourBlog);
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Edit(int id, [Bind(include: "Title, Description, Date, Photo")] OurBlog ourBlog)
        {
            if (!ModelState.IsValid)
            {
                return(View(ourBlog));
            }

            var ourBlogBefore = _context.OurBlogs.Find(id);

            if (ourBlog.Photo != null)
            {
                if (!ourBlog.Photo.isImage())
                {
                    ModelState.AddModelError("Photo", "Photo type is not valid...");
                    return(View(ourBlog));
                }
                //Utilities.Remove before image
                RemoveFile(_env.WebRootPath, "images", ourBlogBefore.Image);
                //Add new Image
                ourBlogBefore.Image = await ourBlog.Photo.SaveAsync(_env.WebRootPath, "images", "asbabphotos");
            }

            ourBlogBefore.Title       = ourBlog.Title;
            ourBlogBefore.Description = ourBlog.Description;

            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public IActionResult Create()
        {
            OurBlog model = new OurBlog();

            return(View(model));
        }