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"));
        }
        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);
            }
        }
Example #4
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 Create(NewsViewModel newsViewModel)
        {
            News news = new News();

            if (ModelState.IsValid)
            {
                if (newsViewModel.Photo != null)
                {
                    ImageUploadService imageUploadService = new ImageUploadService();
                    bool isImageValid = imageUploadService.CheckImageExtension(newsViewModel);
                    if (isImageValid == true)
                    {
                        string fileName = imageUploadService.UploadImage(newsViewModel);
                        news.Photo = fileName;
                    }
                    else
                    {
                        ModelState.AddModelError("PhotoContentTypeError", "The file you are trying to upload is not an image!");
                        return(View(newsViewModel));
                    }
                }
                news.ID      = newsViewModel.ID;
                news.Title   = newsViewModel.Title;
                news.Content = newsViewModel.Content;
                List <Users> allUsers    = UnitOfWork.UOW.UserRepository.GetAll();
                Users        currentUser = allUsers.Where(x => x.ID == SessionDTO.ID).FirstOrDefault();
                news.User = currentUser;
                return(base.Create(news));
            }
            else
            {
                return(View(newsViewModel));
            }
        }
Example #6
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 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));
            }
        }
Example #8
0
 private void UpdateButton_Click(object sender, EventArgs e)
 {
     sLocalFile           = CreateBitmap(UserStatusText.Text);
     Description          = "STATUS|" + UserStatusText.Text;
     progressBar1.Visible = true;
     ImageUploadService.UploadImage(sLocalFile,
                                    Client_UploadFileCompleted, Client_UploadProgressChanged, false);
 }
        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));
                }
            }
        }
Example #10
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"));
        }
Example #11
0
 public UploadController()
 {
     _service = new ImageUploadService();
 }
Example #12
0
 public ImageUploader(Image image)
 {
     Image = image;
     imageUploadService = new ImageUploadService();
 }
 public PostsController(IRepository <Post> postsRepository, PostService postsService, ImageUploadService imageUploadService)
 {
     _postsRepository    = postsRepository;
     _postsService       = postsService;
     _imageUploadService = imageUploadService;
 }
 public ImageUploadController(ImageUploadService imageUploadService)
 {
     _imageUploadService = imageUploadService;
 }
Example #15
0
 public EmbeddedImageService(ImageUploadService uploadService, IImageRepository repository)
 {
     _uploadService = uploadService;
     _repository    = repository;
 }
Example #16
0
 private void UploadButton_Click(object sender, EventArgs e)
 {
     ImageUploadService.UploadImage(sLocalFile,
                                    Client_UploadFileCompleted, Client_UploadProgressChanged, HDBox.Checked);
 }
Example #17
0
 public EditModel(AppDbContext context, ImageUploadService imageUploadService)
 {
     this._context            = context;
     this._imageUploadService = imageUploadService;
 }