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));
                }
            }
        }
Exemple #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"));
        }
Exemple #3
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));
            }
        }
        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"));
        }
        private async void ImageUpload(string deviceId)
        {
            try
            {
                using (Windows.Storage.Streams.InMemoryRandomAccessStream captureStream = new Windows.Storage.Streams.InMemoryRandomAccessStream())
                {
                    await mediaCapture.CapturePhotoToStreamAsync(ImageEncodingProperties.CreateJpeg(), captureStream);

                    await captureStream.FlushAsync();

                    captureStream.Seek(0);

                    // Drops file onto device file system for debugging only
#if DEBUG
                    IStorageFile photoFile = await KnownFolders.PicturesLibrary.CreateFileAsync("Timelapse.jpg", CreationCollisionOption.ReplaceExisting);

                    ImageEncodingProperties imageProperties = ImageEncodingProperties.CreateJpeg();
                    await mediaCapture.CapturePhotoToStorageFileAsync(imageProperties, photoFile);
#endif
                    LoggingService.Log("ImageUploadService Upload starting");
                    ImageUploadService.Upload(deviceId, captureStream);
                    LoggingService.Log("ImageUploadService Upload done");
                }
            }
            catch (Exception ex)
            {
                LoggingService.Error($"Image capture or upload failed ", ex);
            }
        }
Exemple #6
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Image oldLogo = null;

            if (Id.HasValue)
            {
                Company.Id = Id.Value;
                var logoQuery = from c in _context.Companies
                                where c.Id == Company.Id
                                select c.Logo;
                oldLogo = logoQuery.FirstOrDefault();
            }

            if (Logo != null)
            {
                Company.Logo = await _imageUploadService.Upload(Logo);
            }

            _context.Update(Company);
            await _context.SaveChangesAsync();

            if (oldLogo != null)
            {
                _context.Remove(oldLogo);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("Details", new { Id = Company.Id }));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Image oldLogo = null;

            if (Id.HasValue)
            {
                Project.Id = Id.Value;
                var logoQuery = from p in _context.Projects
                                where p.Id == Project.Id
                                select p.Logo;
                oldLogo = logoQuery.FirstOrDefault();
            }

            if (Logo != null)
            {
                Project.Logo = await _imageUploadService.Upload(Logo);
            }

            _context.Update(Project);
            await _context.SaveChangesAsync();

            if (oldLogo != null)
            {
                _context.Remove(oldLogo);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("Index"));
        }
        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));
            }
        }
Exemple #10
0
        public ActionResult Index(HttpPostedFileBase image)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            var uri = _service.Upload(image);

            return(RedirectToAction("Play", new { uri = uri }));
        }
Exemple #11
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"));
        }
Exemple #12
0
 public void Run()
 {
     imageUploadService.Upload(Image);
     Image.Close();
 }