예제 #1
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"));
        }
예제 #2
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));
        }
예제 #3
0
        public async Task <IActionResult> CreateNews(NewsModel model, IFormFile file)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var entity = new News();

            if (file != null)
            {
                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);
            }

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

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

                return(View(new NewsModel()));
            }

            ViewBag.ErrorMessage = _newsService.ErrorMessage;
            return(View(model));
        }
예제 #4
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>()));
        }
예제 #5
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>()));
        }