Пример #1
0
        public ActionResult InsertSlider(SliderVM gelenSlider, HttpPostedFileBase resim)
        {
            string             OrgimagePath   = "~/Upload/Slider/OrjPath";
            string             SmallimagePath = "~/Upload/Slider/SmallPath";
            string             LargeimagePath = "~/Upload/Slider/LargePath";
            string             uniqFileName   = "";
            ImageUploadService svc            = ImageUploadService.CreateService(resim);

            uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);

            SliderVM vmodel    = new SliderVM();
            Slider   eklenecek = new Slider();

            if (ModelState.IsValid)
            {
                if (resim != null)
                {
                    svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                }
                eklenecek.Description = gelenSlider.Description;
                eklenecek.ImageUrl    = uniqFileName;
                _UnitOfWork.GetRepository <Slider>().Insert(eklenecek);
                _UnitOfWork.SaveChanges();
                return(RedirectToAction("Index", "AdminSlider"));
            }
            else
            {
                return(View(vmodel));
            }
        }
Пример #2
0
        public ActionResult SliderDetail(SliderVM modelSlider, HttpPostedFileBase resim)
        {
            Slider gelenSlider = _UnitOfWork.GetRepository <Slider>().GetById(modelSlider.Id);

            gelenSlider.Id          = modelSlider.Id;
            gelenSlider.Description = modelSlider.Description;
            if (resim == null && modelSlider.ImageUrl != "default.png")
            {
                gelenSlider.ImageUrl = modelSlider.ImageUrl;
            }
            else if (resim == null)
            {
                gelenSlider.ImageUrl = "default.png";
            }
            else
            {
                Image photoThumb                = Image.FromStream(resim.InputStream, true, true);
                ImageUploadService svc          = ImageUploadService.CreateService(resim);
                string             uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);

                svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                gelenSlider.ImageUrl = uniqFileName;
            }
            _UnitOfWork.GetRepository <Slider>().Update(gelenSlider);
            _UnitOfWork.SaveChanges();
            return(RedirectToAction("Index", "AdminSlider"));
        }
        public ActionResult CategoryDetail(CategoryVM modelCategory, HttpPostedFileBase resim)
        {
            //Category gelenCat = _CategoryService.getCategoryDetail(gelenCategory.Id);
            Category gelenCat = _UnitOfWork.GetRepository <Category>().GetById(modelCategory.Id);

            gelenCat.Id   = gelenCat.Id;
            gelenCat.Name = modelCategory.Name;
            gelenCat.ServiceDescription = modelCategory.ServiceDescription;
            gelenCat.TopCatId           = modelCategory.TopCatId;

            if (resim == null && modelCategory.CatImage != "default.png")
            {
                gelenCat.CatImage = modelCategory.CatImage;
            }
            else if (resim == null)
            {
                gelenCat.CatImage = "default.png";
            }
            else
            {
                Image photoThumb                = Image.FromStream(resim.InputStream, true, true);
                ImageUploadService svc          = ImageUploadService.CreateService(resim);
                string             uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);

                svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                gelenCat.CatImage = uniqFileName;
            }

            _UnitOfWork.GetRepository <Category>().Update(gelenCat);
            _UnitOfWork.SaveChanges();
            return(RedirectToAction("Index", "AdminCategory"));
        }
        public ActionResult PictureDetail(PictureVM modelPicture, HttpPostedFileBase resim)
        {
            Picture gelenPicture = _UnitOfWork.GetRepository <Picture>().GetById(modelPicture.Id);

            gelenPicture.CatId = modelPicture.CatId;
            if (resim == null && modelPicture.ImagePath != "default.png")
            {
                gelenPicture.ImagePath = modelPicture.ImagePath;
            }
            else if (resim == null)
            {
                gelenPicture.ImagePath = "default.png";
            }
            else
            {
                Image photoThumb                = Image.FromStream(resim.InputStream, true, true);
                ImageUploadService svc          = ImageUploadService.CreateService(resim);
                string             uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);

                svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                gelenPicture.ImagePath = uniqFileName;
            }
            _UnitOfWork.GetRepository <Picture>().Update(gelenPicture);
            _UnitOfWork.SaveChanges();
            return(RedirectToAction("Index", "AdminPicture"));
        }
        public ActionResult InsertPicture(PictureVM gelenPicture, HttpPostedFileBase resim)
        {
            string OrgimagePath   = "~/Upload/Picture/OrjPath";
            string SmallimagePath = "~/Upload/Picture/SmallPath";
            string LargeimagePath = "~/Upload/Picture/LargePath";
            string uniqFileName   = "";

            ImageUploadService svc = ImageUploadService.CreateService(resim);

            uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);
            PictureVM vmodel = new PictureVM();

            Picture eklenecek = new Picture();

            if (ModelState.IsValid)
            {
                if (resim != null)
                {
                    svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                }
                eklenecek.CatId     = gelenPicture.CatId;
                eklenecek.ImagePath = uniqFileName;
                _UnitOfWork.GetRepository <Picture>().Insert(eklenecek);
                _UnitOfWork.SaveChanges();
                return(RedirectToAction("Index", "AdminPicture"));
            }
            else
            {
                return(View(vmodel));
            }
        }
        public ActionResult InsertCategory(CategoryVM gelenCategory, HttpPostedFileBase resim)
        {
            string             OrgimagePath   = "~/Upload/Category/OrjPath";
            string             SmallimagePath = "~/Upload/Category/SmallPath";
            string             LargeimagePath = "~/Upload/Category/LargePath";
            string             uniqFileName   = "";
            ImageUploadService svc            = ImageUploadService.CreateService(resim);

            uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);

            CategoryVM vmodel = new CategoryVM();

            vmodel.drpcategories = _CategoryService.getDrpCategories();
            Category eklenecek = new Category();

            if (gelenCategory.TopCatId == 0)
            {
                if (resim != null)
                {
                    svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                }
                eklenecek.Name               = gelenCategory.Name;
                eklenecek.Description        = gelenCategory.Description;
                eklenecek.CatImage           = uniqFileName;
                eklenecek.ServiceDescription = gelenCategory.ServiceDescription;
                eklenecek.TopCatId           = 0;
                _UnitOfWork.GetRepository <Category>().Insert(eklenecek);
                _UnitOfWork.SaveChanges();
                return(RedirectToAction("Index", "AdminCategory"));
            }
            else
            {
                if (ModelState.IsValid)
                {
                    if (resim != null)
                    {
                        svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                    }
                    eklenecek.Name               = gelenCategory.Name;
                    eklenecek.Description        = gelenCategory.Description;
                    eklenecek.CatImage           = uniqFileName;
                    eklenecek.ServiceDescription = gelenCategory.ServiceDescription;
                    eklenecek.TopCatId           = gelenCategory.TopCatId;
                    _UnitOfWork.GetRepository <Category>().Insert(eklenecek);
                    _UnitOfWork.SaveChanges();
                    return(RedirectToAction("Index", "AdminCategory"));
                }
                else
                {
                    return(View(vmodel));
                }
            }
        }
Пример #7
0
        public ActionResult EditSiteInfo(SiteInfoVM modelSiteInfo, HttpPostedFileBase resim)
        {
            SiteInfo gelenSiteInfo = _UnitOfWork.GetRepository <SiteInfo>().GetById(modelSiteInfo.Id);

            gelenSiteInfo.Id               = modelSiteInfo.Id;
            gelenSiteInfo.SiteUrl          = modelSiteInfo.SiteUrl;
            gelenSiteInfo.CompanyName      = modelSiteInfo.CompanyName;
            gelenSiteInfo.SiteName         = modelSiteInfo.SiteName;
            gelenSiteInfo.MetaTag          = modelSiteInfo.MetaTag;
            gelenSiteInfo.Description      = modelSiteInfo.Description;
            gelenSiteInfo.Address          = modelSiteInfo.Address;
            gelenSiteInfo.Phone1           = modelSiteInfo.Phone1;
            gelenSiteInfo.Phone2           = modelSiteInfo.Phone2;
            gelenSiteInfo.Phone3           = modelSiteInfo.Phone3;
            gelenSiteInfo.Email1           = modelSiteInfo.Email1;
            gelenSiteInfo.Email2           = modelSiteInfo.Email2;
            gelenSiteInfo.Email3           = modelSiteInfo.Email3;
            gelenSiteInfo.Facebook         = modelSiteInfo.Facebook;
            gelenSiteInfo.Twitter          = modelSiteInfo.Twitter;
            gelenSiteInfo.Instagram        = modelSiteInfo.Instagram;
            gelenSiteInfo.Youtube          = modelSiteInfo.Youtube;
            gelenSiteInfo.SiteDesignAgency = modelSiteInfo.SiteDesignAgency;
            gelenSiteInfo.SiteMap          = modelSiteInfo.SiteMap;
            gelenSiteInfo.AboutText        = modelSiteInfo.AboutText;
            gelenSiteInfo.VisionText       = modelSiteInfo.VisionText;
            gelenSiteInfo.MissionText      = modelSiteInfo.MissionText;
            gelenSiteInfo.Service          = modelSiteInfo.Service;
            gelenSiteInfo.CompanyName      = modelSiteInfo.CompanyName;

            if (resim == null && modelSiteInfo.Logo != "default.png")
            {
                gelenSiteInfo.Logo = modelSiteInfo.Logo;
            }
            else if (resim == null)
            {
                gelenSiteInfo.Logo = "default.png";
            }
            else
            {
                Image photoThumb                = Image.FromStream(resim.InputStream, true, true);
                ImageUploadService svc          = ImageUploadService.CreateService(resim);
                string             uniqFileName = svc.CreateUniqName(resim.FileName, OrgimagePath);

                svc.Upload(OrgimagePath, SmallimagePath, LargeimagePath, uniqFileName);
                gelenSiteInfo.Logo = uniqFileName;
            }
            _UnitOfWork.GetRepository <SiteInfo>().Update(gelenSiteInfo);
            _UnitOfWork.SaveChanges();
            return(RedirectToAction("Index", "AdminSiteInfo"));
        }