public IActionResult CreateProduct(ProductModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var entity = new Product()
            {
                Name        = model.Name,
                ImageUrl    = model.ImageUrl == null ? "urun-resim-yok.png" : model.ImageUrl,
                Description = model.Description,
                Price       = model.Price
            };

            if (_productService.Create(entity))
            {
                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Ürün"),
                    Title      = Toastr.GetTitle("Ürün"),
                    ToastrType = ToastrType.Success
                });

                return(View(new ProductModel()));
            }

            ViewBag.ErrorMessage = _productService.ErrorMessage;
            return(View(model));
        }
Beispiel #2
0
        public async Task <IActionResult> CreateBanner(IFormFile file)
        {
            if (file != null)
            {
                var entity = new BannerImage()
                {
                    ImageUrl = file.FileName
                };

                var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\banner", file.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                    await file.CopyToAsync(stream);

                if (_bannerImageService.Create(entity))
                {
                    ToastrService.AddToUserQueue(new Toastr()
                    {
                        Message    = Toastr.GetMessage("Banner Resmi"),
                        Title      = Toastr.GetTitle("Banner"),
                        ToastrType = ToastrType.Success
                    });

                    return(RedirectToAction("BannerList"));
                }
            }

            ViewBag.ErrorMessage = _bannerImageService.ErrorMessage;
            return(RedirectToAction("BannerList"));
        }
Beispiel #3
0
        public async Task <IActionResult> CreateService(ServiceModel model, IFormFile file)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            var entity = new Service();

            if (file != null)
            {
                entity.ImageUrl = file.FileName;
                var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\about\service", file.FileName);
                using (var stream = new FileStream(path, FileMode.Create))
                    await file.CopyToAsync(stream);
            }

            entity.Title       = model.Title;
            entity.Description = model.Description;

            if (_aboutServicesService.Create(entity))
            {
                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Servis"),
                    Title      = Toastr.GetTitle("Servis"),
                    ToastrType = ToastrType.Success
                });

                return(View(new ServiceModel()));
            }

            ViewBag.ErrorMessage = _aboutServicesService.ErrorMessage;
            return(View(model));
        }
        public IActionResult DeleteCategory(int id)
        {
            var entity = _categoryService.GetById(id);

            if (entity != null)
            {
                _categoryService.Delete(entity);

                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Kategori", EntityStatus.Delete),
                    Title      = Toastr.GetTitle("Kategori", EntityStatus.Delete),
                    ToastrType = ToastrType.Error
                });
            }

            return(RedirectToAction("CategoryList"));
        }
        public IActionResult CreateCategory(CategoryModel model)
        {
            var entity = new Category()
            {
                Name = model.Name
            };

            _categoryService.Create(entity);

            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Kategori"),
                Title      = Toastr.GetTitle("Kategori"),
                ToastrType = ToastrType.Success
            });

            return(View());
        }
Beispiel #6
0
        public IActionResult DeleteBanner(int id)
        {
            var entity = _bannerImageService.GetById(id);

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

            _bannerImageService.Delete(entity);
            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Banner Resmi", EntityStatus.Delete),
                Title      = Toastr.GetTitle("Banner", EntityStatus.Delete),
                ToastrType = ToastrType.Error
            });

            return(RedirectToAction("BannerList"));
        }
Beispiel #7
0
        public IActionResult DeleteClientLogo(int id)
        {
            var entity = _clientsLogoService.GetById(id);

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

            _clientsLogoService.Delete(entity);
            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Partner Logosu", EntityStatus.Delete),
                Title      = Toastr.GetTitle("Logo", EntityStatus.Delete),
                ToastrType = ToastrType.Error
            });

            return(RedirectToAction("ClientsLogoList"));
        }
Beispiel #8
0
        public IActionResult DeleteService(int id)
        {
            var entity = _aboutServicesService.GetById(id);

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

            _aboutServicesService.Delete(entity);
            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Servis", EntityStatus.Delete),
                Title      = Toastr.GetTitle("Servis", EntityStatus.Delete),
                ToastrType = ToastrType.Error
            });

            return(RedirectToAction("ServiceManageList"));
        }
        public IActionResult DeleteProduct(int id)
        {
            var entity = _productService.GetById(id);

            if (entity != null)
            {
                _productService.Delete(entity);

                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Ürün", EntityStatus.Delete),
                    Title      = Toastr.GetTitle("Ürün", EntityStatus.Delete),
                    ToastrType = ToastrType.Error
                });
            }


            return(RedirectToAction("ProductList"));
        }
Beispiel #10
0
        public IActionResult EditCategory(CategoryModel model)
        {
            var entity = _categoryService.GetById(model.Id);

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

            entity.Name = model.Name;
            _categoryService.Update(entity);

            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Kategori", EntityStatus.Update),
                Title      = Toastr.GetTitle("Kategori", EntityStatus.Update),
                ToastrType = ToastrType.Info
            });

            return(RedirectToAction("CategoryList"));
        }
Beispiel #11
0
        public async Task <IActionResult> EditNews(NewsModel model, IFormFile file)
        {
            var entity = _newsService.GetById(model.Id);

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

            if (ModelState.IsValid)
            {
                entity.Title       = model.Title;
                entity.Author      = model.Author;
                entity.Description = model.Description;
                entity.DateTime    = model.DateTime;

                if (file != null)
                {
                    FileFunctions.DeletePreviousImage(Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\news", entity.ImageUrl));

                    entity.ImageUrl = file.FileName;
                    var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\news", file.FileName);
                    using (var stream = new FileStream(path, FileMode.Create))
                        await file.CopyToAsync(stream);
                }

                _newsService.Update(entity);
                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Haber", EntityStatus.Update),
                    Title      = Toastr.GetTitle("Haber", EntityStatus.Update),
                    ToastrType = ToastrType.Info
                });

                return(RedirectToAction("NewsList"));
            }

            ViewBag.ErrorMessage = _newsService.ErrorMessage;
            return(View(model));
        }
Beispiel #12
0
        public async Task <IActionResult> EditProduct(ProductModel model, int[] categoryIds, IFormFile file)
        {
            var entity = _productService.GetById(model.Id);

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

            if (ModelState.IsValid)
            {
                entity.Name        = model.Name;
                entity.Description = model.Description;
                entity.Price       = model.Price;

                if (file != null)
                {
                    entity.ImageUrl = file.FileName;
                    var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\product", file.FileName);
                    using (var stream = new FileStream(path, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }
                }

                _productService.Update(entity, categoryIds);

                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Ürün", EntityStatus.Update),
                    Title      = Toastr.GetTitle("Ürün", EntityStatus.Update),
                    ToastrType = ToastrType.Info
                });

                return(RedirectToAction("ProductList"));
            }

            ViewBag.Categories = _categoryService.GetAll();
            return(View(model));
        }
Beispiel #13
0
        public async Task <IActionResult> UpdateBanner(int?id, IFormFile file)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var entity = _bannerImageService.GetById((int)id);

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

            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    entity.ImageUrl = file.FileName;
                    var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\banner", file.FileName);
                    using (var stream = new FileStream(path, FileMode.Create))
                        await file.CopyToAsync(stream);
                }

                _bannerImageService.Update(entity);
                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Banner Resmi", EntityStatus.Update),
                    Title      = Toastr.GetTitle("Banner", EntityStatus.Update),
                    ToastrType = ToastrType.Info
                });

                return(RedirectToAction("BannerList"));
            }

            ViewBag.ErrorMessage = _bannerImageService.ErrorMessage;
            return(RedirectToAction("BannerList"));
        }
Beispiel #14
0
        public async Task <IActionResult> EditService(ServiceModel model, IFormFile file)
        {
            var entity = _aboutServicesService.GetById(model.Id);

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

            if (ModelState.IsValid)
            {
                entity.Title       = model.Title;
                entity.Description = model.Description;

                if (file != null)
                {
                    entity.ImageUrl = file.FileName;
                    var path = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\about\service", file.FileName);
                    using (var stream = new FileStream(path, FileMode.Create))
                        await file.CopyToAsync(stream);
                }

                _aboutServicesService.Update(entity);
                ToastrService.AddToUserQueue(new Toastr()
                {
                    Message    = Toastr.GetMessage("Servis", EntityStatus.Update),
                    Title      = Toastr.GetTitle("Servis", EntityStatus.Update),
                    ToastrType = ToastrType.Info
                });

                return(RedirectToAction("ServiceManageList"));
            }

            ViewBag.ErrorMessage = _aboutServicesService.ErrorMessage;
            return(View(model));
        }
Beispiel #15
0
        public async Task <IActionResult> AboutManage(AboutModel model, IFormFile about, IFormFile youtubeImage, IFormFile youtubeHomeImage)
        {
            var entity = _aboutService.GetAbout();

            if (ModelState.IsValid)
            {
                entity.AboutTitle         = model.AboutTitle;
                entity.ExperienceYear     = model.ExperienceYear;
                entity.AboutDescription   = model.AboutDescription;
                entity.ValuesTitle        = model.ValuesTitle;
                entity.Founder            = model.Founder;
                entity.Rank               = model.Rank;
                entity.Vision             = model.Vision;
                entity.Mission            = model.Mission;
                entity.WorkProcess        = model.WorkProcess;
                entity.YoutubeUrl         = model.YoutubeUrl;
                entity.YoutubeTitle       = model.YoutubeTitle;
                entity.YoutubeDescription = model.YoutubeDescription;
                entity.DifferentText      = model.DifferentText;
                entity.DifferentKeywords  = model.DifferentKeywords;

                if (about != null)
                {
                    if (about.Length > 0)
                    {
                        var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                        var path     = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\about", fileName);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await about.CopyToAsync(stream);

                            entity.ImageUrl = fileName;
                        }
                    }
                }

                if (youtubeImage != null)
                {
                    if (youtubeImage.Length > 0)
                    {
                        var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                        var path     = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\about", fileName);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await youtubeImage.CopyToAsync(stream);

                            entity.YoutubeImageUrl = fileName;
                        }
                    }
                }

                if (youtubeHomeImage != null)
                {
                    if (youtubeHomeImage.Length > 0)
                    {
                        var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                        var path     = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\about", fileName);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await youtubeHomeImage.CopyToAsync(stream);

                            entity.YoutubeHomeImageUrl = fileName;
                        }
                    }
                }
            }

            _aboutService.Update(entity);
            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Kurumsal Bilgiler", EntityStatus.Update),
                Title      = Toastr.GetTitle("Kurumsal Bilgi", EntityStatus.Update),
                ToastrType = ToastrType.Info
            });

            return(View(entity.EntityConvert <AboutModel>()));
        }
Beispiel #16
0
        public async Task <IActionResult> EditInfo(InfoModel model, IFormFile logoHeader, IFormFile logoFooter)
        {
            var entity = _infoService.GetInfo();

            if (ModelState.IsValid)
            {
                entity.Address      = model.Address;
                entity.Email1       = model.Email1;
                entity.Email2       = model.Email2;
                entity.Tel1         = model.Tel1;
                entity.Tel2         = model.Tel2;
                entity.FacebookUrl  = model.FacebookUrl;
                entity.InstagramUrl = model.InstagramUrl;
                entity.TwitterUrl   = model.TwitterUrl;
                entity.YoutubeUrl   = model.YoutubeUrl;
                entity.MapIframe    = model.MapIframe.ChangeMapUrl();
                entity.SiteTitle    = model.SiteTitle;
                entity.Author       = model.Author;
                entity.Keywords     = model.Keywords;
                entity.Description  = model.Description;

                if (logoHeader != null)
                {
                    if (logoHeader.Length > 0)
                    {
                        var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                        var path     = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\info", fileName);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await logoHeader.CopyToAsync(stream);

                            entity.LogoHeader = fileName;
                        }
                    }
                }

                if (logoFooter != null)
                {
                    if (logoFooter.Length > 0)
                    {
                        var fileName = Path.ChangeExtension(Path.GetRandomFileName(), ".jpg");
                        var path     = Path.Combine(Directory.GetCurrentDirectory(), @"wwwroot\img\info", fileName);
                        using (var stream = new FileStream(path, FileMode.Create))
                        {
                            await logoFooter.CopyToAsync(stream);

                            entity.LogoFooter = fileName;
                        }
                    }
                }
            }

            _infoService.Update(entity);
            ToastrService.AddToUserQueue(new Toastr()
            {
                Message    = Toastr.GetMessage("Firma Bilgileri", EntityStatus.Update),
                Title      = Toastr.GetTitle("Firma Bilgileri", EntityStatus.Update),
                ToastrType = ToastrType.Info
            });

            return(View(entity.EntityConvert <InfoModel>()));
        }