Exemple #1
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)));
        }
        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)));
        }
Exemple #3
0
        public async Task <IActionResult> Edit(Slider slider)
        {
            if (!ModelState.IsValid)
            {
                return(View(slider));
            }

            var sliderDb = await _context.Sliders.FindAsync(slider.Id);

            if (slider.Photo != null)
            {
                try
                {
                    var newPhoto = await slider.Photo.SaveFileAsync(_env.WebRootPath, "images/service/");

                    IFormFileExtension.Delete(_env.WebRootPath, "images/service/", sliderDb.Image);
                    sliderDb.Image = newPhoto;
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again.");
                    return(View(slider));
                }
            }

            sliderDb.Title    = slider.Title;
            sliderDb.Subtitle = slider.Subtitle;
            await _context.SaveChangesAsync();

            TempData["warning"] = "Slayder uğurla dəyişdirildi";
            return(RedirectToAction(nameof(Index)));
        }
Exemple #4
0
        public async Task <IActionResult> RemovePost(int?id)
        {
            if (id != null)
            {
                Team team = await _context.Teams.FirstOrDefaultAsync(t => t.Id == id);

                if (team != null)
                {
                    IFormFileExtension.Delete(_env.WebRootPath, "images/team", team.Image);
                    _context.Teams.Remove(team);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(NotFound());
        }
Exemple #5
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)));
        }
Exemple #6
0
        public async Task <IActionResult> DeleteService(int?id)
        {
            if (id != null)
            {
                var team = await _context.Teams.FirstOrDefaultAsync(s => s.Id == id);

                if (team != null)
                {
                    IFormFileExtension.Delete(_env.WebRootPath, "images/outsource/", team.Image);
                    _context.Teams.Remove(team);
                    await _context.SaveChangesAsync();

                    TempData["danger"] = "İşçi uğurla silindi";
                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(NotFound());
        }
Exemple #7
0
        public async Task <IActionResult> DeleteProduct(int?id)
        {
            if (id != null)
            {
                var product = await _context.Products.FirstOrDefaultAsync(s => s.Id == id);

                if (product != null)
                {
                    IFormFileExtension.Delete(_env.WebRootPath, "images/shop/", product.Image);
                    _context.Products.Remove(product);
                    await _context.SaveChangesAsync();

                    TempData["danger"] = "Məhsul uğurla silindi";
                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(NotFound());
        }
Exemple #8
0
        public async Task <IActionResult> DeleteSlider(int?id)
        {
            if (id != null)
            {
                var slider = await _context.Sliders.FirstOrDefaultAsync(s => s.Id == id);

                if (slider != null)
                {
                    IFormFileExtension.Delete(_env.WebRootPath, "images/service/", slider.Image);
                    _context.Sliders.Remove(slider);
                    await _context.SaveChangesAsync();

                    TempData["danger"] = "Slayder uğurla silindi";
                    return(RedirectToAction(nameof(Index)));
                }
            }

            return(NotFound());
        }
Exemple #9
0
        public async Task <IActionResult> Edit(ProductSpecificationViewModel product)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.Categories = new SelectList(_context.CategoryProducts, "Id", "Name");
                return(View(product));
            }

            var productDb = await _context.Products.FindAsync(product.Id);

            if (product.Photo != null)
            {
                if (!product.Photo.IsImage())
                {
                    ModelState.AddModelError("Photo", "Şəkilin formatı jpg, jpeg, png, svg və ya gif formatında olmalıdır");
                    return(View(product));
                }
                try
                {
                    var newPhoto = await product.Photo.SaveFileAsync(_env.WebRootPath, "images/shop/");

                    IFormFileExtension.Delete(_env.WebRootPath, "images/shop/", productDb.Image);
                    productDb.Image = newPhoto;
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again.");
                    return(View(product));
                }
            }

            productDb.Name              = product.Name;
            productDb.Description       = product.Description;
            productDb.CategoryProductId = product.CategoryProductId;
            productDb.Price             = product.Price;
            await _context.SaveChangesAsync();



            TempData["warning"] = "Məhsul uğurla dəyişdirildi";
            return(RedirectToAction(nameof(Index)));
        }
Exemple #10
0
        public async Task <IActionResult> Edit(Team team)
        {
            if (!ModelState.IsValid)
            {
                return(View(team));
            }



            var teamDb = await _context.Teams.FindAsync(team.Id);

            if (team.Photo != null)
            {
                if (!team.Photo.IsImage())
                {
                    ModelState.AddModelError("Photo", "Şəkilin formatı jpg, jpeg, png, svg və ya gif formatında olmalıdır");
                    return(View(team));
                }
                try
                {
                    var newPhoto = await team.Photo.SaveFileAsync(_env.WebRootPath, "images/outsource/");

                    IFormFileExtension.Delete(_env.WebRootPath, "images/outsource/", teamDb.Image);
                    teamDb.Image = newPhoto;
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again.");
                    return(View(team));
                }
            }

            teamDb.Name     = team.Name;
            teamDb.Position = team.Position;
            await _context.SaveChangesAsync();

            TempData["warning"] = "İşçi uğurla dəyişdirildi";
            return(RedirectToAction(nameof(Index)));
        }
Exemple #11
0
        public async Task <IActionResult> Edit(Models.Service service)
        {
            if (!ModelState.IsValid)
            {
                return(View(service));
            }



            var serviceDb = await _context.Services.FindAsync(service.Id);

            if (service.Photo != null)
            {
                if (!service.Photo.IsImage())
                {
                    ModelState.AddModelError("Photo", "Şəkilin formatı jpg, jpeg, png, svg və ya gif formatında olmalıdır");
                    return(View(service));
                }
                try
                {
                    var newPhoto = await service.Photo.SaveFileAsync(_env.WebRootPath, "images/service/");

                    IFormFileExtension.Delete(_env.WebRootPath, "images/service/", serviceDb.Image);
                    serviceDb.Image = newPhoto;
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again.");
                    return(View(service));
                }
            }

            serviceDb.Name        = service.Name;
            serviceDb.Description = service.Description;
            await _context.SaveChangesAsync();

            TempData["warning"] = "Xidmət uğurla dəyişdirildi";
            return(RedirectToAction(nameof(Index)));
        }
Exemple #12
0
        public async Task <IActionResult> Edit(News news)
        {
            if (!ModelState.IsValid)
            {
                return(View(news));
            }


            var newsDb = await _context.News.FindAsync(news.Id);

            if (news.Photo != null)
            {
                if (!news.Photo.IsImage())
                {
                    ModelState.AddModelError("Photo", "Şəkilin formatı jpg, jpeg, png, svg və ya gif formatında olmalıdır");
                    return(View(news));
                }
                try
                {
                    var newPhoto = await news.Photo.SaveFileAsync(_env.WebRootPath, "images/outsource/");

                    IFormFileExtension.Delete(_env.WebRootPath, "images/outsource/", newsDb.Image);
                    newsDb.Image = newPhoto;
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again.");
                    return(View(news));
                }
            }

            newsDb.Name     = news.Name;
            newsDb.Subtitle = news.Subtitle;
            newsDb.Text     = news.Text;
            await _context.SaveChangesAsync();

            TempData["warning"] = "Xəbər uğurla dəyişdirildi";
            return(RedirectToAction(nameof(Index)));
        }
Exemple #13
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)));
        }
Exemple #14
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)));
        }
Exemple #15
0
        public async Task <IActionResult> Edit(Team team)
        {
            if (!ModelState.IsValid)
            {
                return(View(team));
            }

            var TeamDb = await _context.Teams.FindAsync(team.Id);

            if (team.Photo != null)
            {
                try
                {
                    var newPhoto = await team.Photo.SaveFileAsync(_env.WebRootPath, "images/team");

                    IFormFileExtension.Delete(_env.WebRootPath, "images/team", TeamDb.Image);
                    TeamDb.Image = newPhoto;
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", "Unexpected error happened while saving image. Please, try again.");
                    return(View(team));
                }
            }

            TeamDb.Title    = team.Title;
            TeamDb.SubTitle = team.SubTitle;
            TeamDb.Facebook = team.Facebook;
            TeamDb.Twitter  = team.Twitter;
            TeamDb.Google   = team.Google;
            TeamDb.Linkedin = team.Linkedin;
            TeamDb.Dribble  = team.Dribble;
            await _context.SaveChangesAsync();

            TempData["succes_message"] = "Team was updated successfuly";
            return(RedirectToAction(nameof(Index)));
        }