예제 #1
0
        public async Task <IActionResult> Update(CareerAdvice career)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }
            var dbcareer = _context.CareerAdvices.FirstOrDefault(x => x.Id == career.Id);

            if (dbcareer == null)
            {
                return(View());
            }

            dbcareer.Title      = career.Title;
            dbcareer.Desc       = career.Desc;
            dbcareer.CreateTime = career.CreateTime;

            if (career.Photo != null)
            {
                IFormFileExtension.DeletePath(_env.WebRootPath, "images/blog", dbcareer.Image);
                dbcareer.Image = await career.Photo.SaveImg(_env.WebRootPath, "images/blog");
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #2
0
        public async Task <IActionResult> Update(HowToWork howToWork)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }
            HowToWork dbhowtowork = _context.HowToWorks.FirstOrDefault(x => x.Id == howToWork.Id);

            if (dbhowtowork == null)
            {
                return(NotFound());
            }

            dbhowtowork.Title = howToWork.Title;
            dbhowtowork.Desc  = howToWork.Desc;

            if (howToWork.Photo != null)
            {
                IFormFileExtension.DeletePath(_env.WebRootPath, "images/how-it-work", dbhowtowork.Image);
                dbhowtowork.Image = await howToWork.Photo.SaveImg(_env.WebRootPath, "images/how-it-work");
            }


            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #3
0
        public async Task <IActionResult> Update(OurClient ourClient)
        {
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }
            OurClient dbourclient = _context.OurClients.FirstOrDefault(x => x.Id == ourClient.Id);

            if (ourClient != null)
            {
                IFormFileExtension.DeletePath(_env.WebRootPath, "images/clients", dbourclient.Image);
                dbourclient.Image = await ourClient.Photo.SaveImg(_env.WebRootPath, "images/clients");
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #4
0
        public async Task <IActionResult> Update(BlogUpdateVM blogUpdate)
        {
            ViewBag.Category = new SelectList(_context.Categories.ToList(), "Id", "CategoryName");
            if (!ModelState.IsValid)
            {
                return(NotFound());
            }

            Blog blog = _context.Blogs.FirstOrDefault(x => x.Id == blogUpdate.Id);

            if (blog == null)
            {
                return(NotFound());
            }

            blog.Title          = blogUpdate.Title;
            blog.Description    = blogUpdate.Description;
            blog.AllDescription = blogUpdate.AllDescription;
            blog.AuthorDesc     = blogUpdate.AuthorDesc;
            blog.CreateTime     = blogUpdate.CreateTime;
            blog.Facebook       = blogUpdate.Facebook;
            blog.Twitter        = blogUpdate.Twitter;
            blog.Instagram      = blogUpdate.Instagram;
            blog.Whatsapp       = blogUpdate.Whatsapp;
            blog.AuthorName     = blogUpdate.AuthorName;
            blog.CategoryId     = blogUpdate.CategoryId;


            if (blogUpdate.Photo != null)
            {
                IFormFileExtension.DeletePath(_env.WebRootPath, "images/blog", blog.Image);
                blog.Image = await blogUpdate.Photo.SaveImg(_env.WebRootPath, "images/blog");
            }


            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #5
0
        public async Task <IActionResult> Update(SuccessStorie successStorie)
        {
            //if (!ModelState.IsValid) return NotFound();
            SuccessStorie dbSuccessStorie = _context.SuccessStories.FirstOrDefault(x => x.Id == successStorie.Id);

            if (dbSuccessStorie == null)
            {
                return(NotFound());
            }
            dbSuccessStorie.Desc     = successStorie.Desc;
            dbSuccessStorie.FullName = successStorie.FullName;
            dbSuccessStorie.Postion  = successStorie.Postion;

            if (successStorie.Photo != null)
            {
                IFormFileExtension.DeletePath(_env.WebRootPath, "images/testi", dbSuccessStorie.Image);
                dbSuccessStorie.Image = await successStorie.Photo.SaveImg(_env.WebRootPath, "images/testi");
            }

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }