public ActionResult EditSectorGroup()
        {
            ImageHelperNew.DestroyImageCashAndSession(175, 127);
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (RouteData.Values["id"] != null)
            {
                int  nid      = 0;
                bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                if (isnumber)
                {
                    SectorGroup editrecord = SectorGroupManager.GetSectorGroupById(nid);
                    return(View(editrecord));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Beispiel #2
0
        public JsonResult ReadImageFromPath(string path)
        {
            try
            {
                WorkingImageExtension = Path.GetExtension(path).ToLower();

                byte[] image;
                image = GetImageFromServer(path);

                WorkingImageId = Guid.NewGuid();
                MemoryStream ms           = new MemoryStream(image);
                Image        workingImage = Image.FromStream(ms);

                WorkingImage = ImageHelperNew.ImageToByteArray(workingImage);

                return(Json(WorkingImageId));
            }
            catch (Exception ex)
            {
                string errorMsg = string.Format("Error cropping image: {0}", ex.Message);
                Response.StatusCode = 500;
                Response.Write(errorMsg);
                return(Json(string.Empty));
            }
        }
Beispiel #3
0
        public ActionResult AddImage(Photo newmodel, HttpPostedFileBase uploadfile, string language, string Title)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            Photo p = new Photo();

            if (Session["ModifiedImageId"] != null)
            {
                string imagename = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString();// +Session["WorkingImageExtension"].ToString();
                newmodel.Path = imagename + ".jpeg";
                ImageHelperNew.DestroyImageCashAndSession(0, 0);

                Helpers.ImageHelper.WaterMark(imagename, 100);
            }
            else
            {
                newmodel.Path = "/Content/images/front/noimage.jpeg";
            }

            p.CategoryId  = (int)PhotoTypes.Gallery;
            p.Title       = Title;
            p.Language    = language;
            p.Online      = true;
            p.SortOrder   = 9999;
            p.TimeCreated = DateTime.Now;
            p.Path        = newmodel.Path;

            ViewBag.ProcessMessage = PhotoManager.Save(p);

            return(View());
        }
Beispiel #4
0
        public ActionResult AddOurTeam(OurTeam OurTeammodel, HttpPostedFileBase uploadfile, string txtdate)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    OurTeammodel.Image = "/Content/images/userfiles/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                else
                {
                    OurTeammodel.Image = "/Content/images/front/noimage.jpeg";
                }

                OurTeammodel.PageSlug    = Utility.SetPagePlug(OurTeammodel.Name);
                OurTeammodel.TimeCreated = Utility.ControlDateTime(txtdate);
                ViewBag.ProcessMessage   = OurTeamManager.AddOurTeam(OurTeammodel);
                ModelState.Clear();
                return(View());
            }
            else
            {
                return(View());
            }
        }
Beispiel #5
0
 public ActionResult EditNews()
 {
     if (RouteData.Values["id"] != null)
     {
         int  nid      = 0;
         bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
         if (isnumber)
         {
             ImageHelperNew.DestroyImageCashAndSession(600, 338);
             News editnews  = NewsManager.GetNewsById(nid);
             var  languages = LanguageManager.GetLanguages();
             var  list      = new SelectList(languages, "Culture", "Language");
             ViewBag.LanguageList = list;
             return(View(editnews));
         }
         else
         {
             return(View());
         }
     }
     else
     {
         return(View());
     }
 }
Beispiel #6
0
        public ActionResult Add(Photo newmodel, HttpPostedFileBase uploadfile, string language)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    newmodel.Path = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                else
                {
                    newmodel.Path = "/Content/images/front/noimage.jpeg";
                }
                newmodel.Language      = language;
                newmodel.Online        = true;
                newmodel.SortOrder     = 9999;
                newmodel.TimeCreated   = DateTime.Now;
                ViewBag.ProcessMessage = PhotoManager.Save(newmodel);
                ModelState.Clear();
                // Response.Redirect("/yonetim/haberduzenle/" + newsmodel.NewsId);
                return(View());
            }
            else
            {
                return(View());
            }
        }
 public ActionResult EditReference()
 {
     if (RouteData.Values["id"] != null)
     {
         var languages = LanguageManager.GetLanguages();
         var list      = new SelectList(languages, "Culture", "Language");
         ViewBag.LanguageList = list;
         int  nid      = 0;
         bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
         if (isnumber)
         {
             ImageHelperNew.DestroyImageCashAndSession(169, 62);
             References editreference = ReferenceManager.GetReferenceById(nid);
             var        photos        = PhotoManager.GetList(4, nid);
             ViewBag.Photos = photos;
             return(View(editreference));
         }
         else
         {
             return(View());
         }
     }
     else
     {
         return(View());
     }
     return(View());
 }
Beispiel #8
0
        public ActionResult AddNews()
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            ImageHelperNew.DestroyImageCashAndSession(600, 338);
            return(View());
        }
Beispiel #9
0
        public ActionResult AddNews(IEnumerable <HttpPostedFileBase> attachments, News newsmodel, HttpPostedFileBase uploadfile, string txtdate, string Language)
        {
            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    string imagename = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString();// + Session["WorkingImageExtension"].ToString();
                    newsmodel.NewsImage = imagename + ".jpeg";
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);

                    Helpers.ImageHelper.WaterMark(imagename, 100);
                }
                else
                {
                    newsmodel.NewsImage = "/Content/images/front/noimage.jpeg";
                }

                newsmodel.Language     = Language;
                newsmodel.TypeId       = 0;
                newsmodel.IsMachine    = true;
                newsmodel.PageSlug     = Utility.SetPagePlug(newsmodel.Header);
                newsmodel.TimeCreated  = Utility.ControlDateTime(txtdate);
                ViewBag.ProcessMessage = NewsManager.AddNews(newsmodel);
                Session.Remove("UploadType");
                //foreach (var item in attachments)
                //{
                //    if (item != null && item.ContentLength > 0)
                //    {
                //        Random random = new Random();
                //        int rand = random.Next(1000, 99999999);
                //        new ImageHelper(1024, 768).SaveThumbnail(item, "/Content/images/userfiles/", Utility.SetPagePlug(newsmodel.Header) + "_" + rand + Path.GetExtension(item.FileName));
                //        Photo p = new Photo();
                //        p.CategoryId = (int)PhotoType.News;
                //        p.ItemId = newsmodel.NewsId;
                //        p.Path = "/Content/images/userfiles/" + Utility.SetPagePlug(newsmodel.Header) + "_" + rand + Path.GetExtension(item.FileName);
                //        p.Thumbnail = "/Content/images/userfiles/" + Utility.SetPagePlug(newsmodel.Header) + "_" + rand + Path.GetExtension(item.FileName);
                //        p.Online = true;
                //        p.SortOrder = 9999;
                //        p.Language = "tr";
                //        p.TimeCreated = DateTime.Now;
                //        p.Title = "Haberler";
                //        PhotoManager.Save(p);
                //    }
                //}
                ModelState.Clear();
                // Response.Redirect("/yonetim/haberduzenle/" + newsmodel.NewsId);
                var languages = LanguageManager.GetLanguages();
                var list      = new SelectList(languages, "Culture", "Language");
                ViewBag.LanguageList = list;
                return(View());
            }
            else
            {
                return(View());
            }
        }
        public ActionResult AddSectorGroup()
        {
            ImageHelperNew.DestroyImageCashAndSession(175, 127);
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            return(View());
        }
Beispiel #11
0
        public ActionResult Add()
        {
            var languages = LanguageManager.GetLanguages();
            var countries = EstateManager.GetCountryList();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            var countrylist = new SelectList(countries, "Id", "Name");

            ViewBag.Country = countrylist;
            //ImageHelperNew.DestroyImageCashAndSession(577, 296);
            ImageHelperNew.DestroyImageCashAndSession(750, 483);
            return(View());
        }
Beispiel #12
0
        public ActionResult GetDetailPage(int id, int cid)
        {
            using (MainContext db = new MainContext())
            {
                ImageHelperNew.DestroyImageCashAndSession(1024, 768);

                PropertyModel model = new PropertyModel();
                model.header      = db.ProductHeaders.FirstOrDefault(x => x.CategoryId == cid);
                model.ProductInfo = db.ProductInformation.Where(x => x.ProductId == id).ToList();
                ViewBag.PrId      = id;
                ViewBag.CatId     = cid;
                ViewBag.Details   = db.ProductDetail.Where(x => x.ProductId == id).ToList();
                ViewBag.lang      = db.Product.FirstOrDefault(d => d.ProductId == id).Language;
                return(PartialView("~/Areas/Admin/Views/Product/_detailproptable.cshtml", model));
            }
        }
        public ActionResult AddSectorGroup(SectorGroup newmodel, HttpPostedFileBase uploadfile, HttpPostedFileBase uploadimage)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (ModelState.IsValid)
            {
                //if (uploadimage != null && uploadimage.ContentLength > 0)
                //{
                //    using (System.Drawing.Image image = System.Drawing.Image.FromStream(uploadimage.InputStream, true, true))
                //    {
                //        if (image.Width == 48 && image.Height == 48)
                //        {
                //            Random random = new Random();
                //            int rand = random.Next(1000, 99999999);
                //            uploadimage.SaveAs(Server.MapPath("/Content/images/projects/" + Utility.SetPagePlug(newmodel.GroupName) + "_" + rand + Path.GetExtension(uploadimage.FileName)));
                //            newmodel.SectorGroupLogo = "/Content/images/projects/" + Utility.SetPagePlug(newmodel.GroupName) + "_" + rand + Path.GetExtension(uploadimage.FileName);
                //        }
                //        else
                //        {
                //            TempData["ImageSizeError"] = "Eklemiş olduğunuz ikonun boyutları 48x48 olmalıdır...";
                //            return View();
                //        }
                //    }
                //}
                if (Session["ModifiedImageId"] != null)
                {
                    newmodel.SectorGroupLogo = "/Content/images/userfiles/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                else
                {
                    newmodel.SectorGroupLogo = "/Content/images/front/noimage.jpeg";
                }
                newmodel.PageSlug      = Utility.SetPagePlug(newmodel.GroupName);
                newmodel.TimeCreated   = DateTime.Now;
                ViewBag.ProcessMessage = SectorGroupManager.AddSectorGroup(newmodel);
                ModelState.Clear();

                return(View());
            }
            else
            {
                return(View());
            }
        }
Beispiel #14
0
        /// <summary>
        /// Processes the uploaded image.
        /// </summary>
        /// <param name="uploadedFileMeta">The uploaded file meta.</param>
        /// <returns>Image Id</returns>
        private Guid ProcessUploadedImage(MediaAssetUploadModel uploadedFileMeta)
        {
            // Get the file extension
            WorkingImageExtension = Path.GetExtension(uploadedFileMeta.Filename).ToLower();
            string[] allowedExtensions = { ".png", ".jpeg", ".jpg", ".gif" }; // Make sure it is an image that can be processed
            if (allowedExtensions.Contains(WorkingImageExtension))
            {
                WorkingImageId = Guid.NewGuid();
                Image workingImage = new Bitmap(uploadedFileMeta.fileData.InputStream);
                WorkingImage = ImageHelperNew.ImageToByteArray(workingImage);
            }
            else
            {
                throw new Exception("Cannot process files of this type.");
            }

            return(WorkingImageId);
        }
Beispiel #15
0
        public ActionResult Edit()
        {
            ImageHelperNew.DestroyImageCashAndSession(750, 483, 250, 161);
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            var countries = EstateManager.GetCountryList();

            if (RouteData.Values["id"] != null)
            {
                int  nid      = 0;
                bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                if (isnumber)
                {
                    Estate record = EstateManager.GetEstateById(nid);

                    var countrylist = new SelectList(countries, "Id", "Name", record.CountryId);
                    ViewBag.Country = countrylist;

                    var towns    = EstateManager.GetTownList(record.CountryId);
                    var townList = new SelectList(towns, "Id", "Name", record.TownId);
                    ViewBag.Town = townList;

                    var districts     = EstateManager.GetDistrictList(record.TownId);
                    var districtsList = new SelectList(districts, "Id", "Name", record.DistrictId);
                    ViewBag.District = districtsList;

                    return(View(record));
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Beispiel #16
0
        public ActionResult EditOurTeam(OurTeam OurTeammodel, HttpPostedFileBase uploadfile)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    OurTeammodel.Image = "/Content/images/userfiles/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }

                OurTeammodel.PageSlug = Utility.SetPagePlug(OurTeammodel.Name);

                if (RouteData.Values["id"] != null)
                {
                    int  nid      = 0;
                    bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                    if (isnumber)
                    {
                        OurTeammodel.OurTeamId = nid;
                        ViewBag.ProcessMessage = OurTeamManager.EditOurTeam(OurTeammodel);
                        return(View(OurTeammodel));
                    }
                    else
                    {
                        ViewBag.ProcessMessage = false;
                        return(View(OurTeammodel));
                    }
                }

                return(View());
            }
            else
            {
                return(View());
            }
        }
Beispiel #17
0
        public ActionResult AddReference(References newmodel, HttpPostedFileBase uploadfile, IEnumerable <HttpPostedFileBase> attachments, string language)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    newmodel.Logo = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                else
                {
                    newmodel.Logo = "/Content/images/front/noimage.jpeg";
                }
                //if (uploadfile != null && uploadfile.ContentLength > 0)
                //{
                //    Random random = new Random();
                //    int rand = random.Next(1000, 99999999);
                //    new ImageHelper(240, 240).SaveThumbnail(uploadfile,"/Content/images/references/", Utility.SetPagePlug(newmodel.ReferenceName) + "_" + rand + Path.GetExtension(uploadfile.FileName));
                //    newmodel.Logo = "/Content/images/references/" + Utility.SetPagePlug(newmodel.ReferenceName) + "_" + rand + Path.GetExtension(uploadfile.FileName);
                //}
                //else
                //{
                //    newmodel.Logo = "/Content/images/front/noimage.jpeg";
                //}

                newmodel.Language      = language;
                newmodel.SortOrder     = 9999;
                newmodel.TimeCreated   = DateTime.Now;
                ViewBag.ProcessMessage = ReferenceManager.AddReference(newmodel);

                //foreach (var item in attachments)
                //{
                //    if (item != null && item.ContentLength > 0)
                //    {
                //        item.SaveAs(Server.MapPath("/Content/images/userfiles/")+item.FileName);
                //        Random random = new Random();
                //        int rand = random.Next(1000, 99999999);
                //        string path = Utility.SetPagePlug(newmodel.ReferenceName) + "_" + rand + Path.GetExtension(item.FileName);
                //        new ImageHelper(1020, 768).SaveThumbnail(item, "/Content/images/userfiles/", path);

                //        rand = random.Next(1000, 99999999);
                //        string thumbnail = Utility.SetPagePlug(newmodel.ReferenceName) + "_" + rand + Path.GetExtension(item.FileName);

                //       // Image img = Image.FromFile(Server.MapPath("/Content/images/userfiles/") + item.FileName);

                //        Bitmap bmp = new Bitmap(Server.MapPath("/Content/images/userfiles/") + item.FileName);

                //    Bitmap bmp2 = new Bitmap(bmp);

                //  using (Bitmap Orgbmp = bmp2)
                //   {

                //       int sabit = 90;
                //       Size Boyut = new Size(210, 125);
                //       Bitmap ReSizedThmb = new Bitmap(Orgbmp, Boyut);
                //        ReSizedThmb.Save(Server.MapPath("/Content/images/userfiles/")+thumbnail);
                //       bmp.Dispose();
                //         bmp2.Dispose();
                //       Orgbmp.Dispose();
                //       GC.Collect();
                //    }

                //       //new ImageHelper(300, 280).ResizeFromStream("/Content/images/userfiles/",thumbnail,img);
                //        Photo p = new Photo();
                //        p.CategoryId = (int)PhotoType.Reference;
                //        p.ItemId = newmodel.ReferenceId;
                //        p.Path = "/Content/images/userfiles/" + path;
                //        p.Thumbnail = "/Content/images/userfiles/" + thumbnail;
                //        p.Online = true;
                //        p.SortOrder = 9999;
                //        p.Language = language;
                //        p.TimeCreated = DateTime.Now;
                //        p.Title = newmodel.ReferenceName;
                //        PhotoManager.Save(p);
                //    }
                //}



                ModelState.Clear();
                // Response.Redirect("/yonetim/haberduzenle/" + newsmodel.NewsId);
                return(View());
            }
            else
            {
                return(View());
            }
        }
Beispiel #18
0
 public ActionResult imageUploadAndCrop()
 {
     ImageHelperNew.DestroyImageCashAndSession(0, 0);
     return(View("_imageUploadAndCrop"));
 }
Beispiel #19
0
        /// <summary>
        /// Modifies an image image.
        /// </summary>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <param name="w">The w.</param>
        /// <param name="h">The h.</param>
        /// <param name="modType">Type of the mod. Crop or Resize</param>
        /// <returns>New Image Id</returns>
        private string ModifyImage(int x, int y, int w, int h, ImageModificationType modType, bool?withextension)
        {
            ModifiedImageId = Guid.NewGuid();
            Image img = ImageHelperNew.ByteArrayToImage(WorkingImage);
            int   genislik, yukseklik;

            if (Session["UploadType"] == null)
            {
                genislik  = Convert.ToInt32(Session["_minwidth2"].ToString());
                yukseklik = Convert.ToInt32(Session["_minheight2"].ToString());
            }
            else
            {
                genislik  = Convert.ToInt32(Session["_minwidth"].ToString());
                yukseklik = Convert.ToInt32(Session["_minheight"].ToString());
            }

            using (System.Drawing.Bitmap _bitmap = new System.Drawing.Bitmap(genislik, yukseklik))
            {
                _bitmap.SetResolution(img.HorizontalResolution, img.VerticalResolution);
                using (Graphics _graphic = Graphics.FromImage(_bitmap))
                {
                    _graphic.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                    _graphic.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
                    _graphic.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
                    _graphic.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;

                    if (modType == ImageModificationType.Crop)
                    {
                        //_graphic.DrawImage(img, 0, 0, w, h);
                        //_graphic.DrawImage(img, new Rectangle(0, 0, w, h), x, y, w, h, GraphicsUnit.Pixel);

                        // Aşağıdaki kodu ben ekliyorum. Crop işleminden sonra resize etmek için..


                        _graphic.DrawImage(img, new Rectangle(0, 0, genislik, yukseklik), x, y, w, h, GraphicsUnit.Pixel);
                    }
                    else if (modType == ImageModificationType.Resize)
                    {
                        _graphic.DrawImage(img, 0, 0, img.Width, img.Height);
                        _graphic.DrawImage(img, new Rectangle(0, 0, W_FixedSize, H_FixedSize), 0, 0, img.Width, 0, GraphicsUnit.Pixel);
                    }

                    string extension = WorkingImageExtension;

                    // If the image is a gif file, change it into png
                    if (extension.EndsWith("gif", StringComparison.OrdinalIgnoreCase))
                    {
                        extension = ".png";
                    }

                    using (EncoderParameters encoderParameters = new EncoderParameters(1))
                    {
                        encoderParameters.Param[0] = new EncoderParameter(Encoder.Quality, 100L);
                        ModifiedImage = ImageHelperNew.ImageToByteArray(_bitmap, extension, encoderParameters);
                    }
                }
            }

            Image CoreppedImg = ImageHelperNew.ByteArrayToImage(ModifiedImage);

            //CoreppedImg.Save(Server.MapPath("/Content/images/userfiles/newbig/" + ModifiedImageId + WorkingImageExtension));
            //CoreppedImg.Save(Server.MapPath("/Content/images/userfiles/news/" + ModifiedImageId));

            if (withextension == false)
            {
                CoreppedImg.Save(Server.MapPath("/Content/images/userfiles/news/" + ModifiedImageId));
            }
            else
            {
                CoreppedImg.Save(Server.MapPath("/Content/images/userfiles/news/" + ModifiedImageId + WorkingImageExtension));
            }
            return(ModifiedImageId.ToString());
        }
Beispiel #20
0
        public ActionResult Edit(IEnumerable <HttpPostedFileBase> attachments, Estate record, HttpPostedFileBase uploadfile, HttpPostedFileBase fileDosya)
        {
            var    languages = LanguageManager.GetLanguages();
            string lang      = "";

            if (RouteData.Values["lang"] == null)
            {
                lang = "tr";
            }
            else
            {
                lang = RouteData.Values["lang"].ToString();
            }
            var list = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            if (ModelState.IsValid)
            {
                //if (uploadfile != null && uploadfile.ContentLength > 0)
                //{
                //    Random random = new Random();
                //    int rand = random.Next(1000, 99999999);
                //    new ImageHelper(280, 240).SaveThumbnail(uploadfile, "/Content/images/Photos/", Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(uploadfile.FileName));
                //    record.Photo = "/Content/images/Photos/" + Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(uploadfile.FileName);
                //}

                if (Session["ModifiedImageId"] != null)
                {
                    record.Photo = "/Content/images/userfiles/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }

                if (RouteData.Values["id"] != null)
                {
                    int  nid      = 0;
                    bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                    if (isnumber)
                    {
                        if (fileDosya != null)
                        {
                            fileDosya.SaveAs(Server.MapPath("/Content/images/estates/") + fileDosya.FileName);
                            record.EmlakDosyasi = "/Content/images/estates/" + fileDosya.FileName;
                        }


                        record.Id = nid;
                        ViewBag.ProcessMessage = EstateManager.EditEstate(record);
                        //return View(record);
                        foreach (var item in attachments)
                        {
                            if (item != null && item.ContentLength > 0)
                            {
                                Random random = new Random();
                                int    rand   = random.Next(1000, 99999999);
                                new ImageHelper(1024, 768).SaveThumbnail(item, "/Content/images/userfiles/", Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(item.FileName));
                                Photo p = new Photo();
                                p.CategoryId  = (int)PhotoType.Estate;
                                p.ItemId      = record.Id;
                                p.Path        = "/Content/images/userfiles/" + Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(item.FileName);
                                p.Thumbnail   = "/Content/images/userfiles/" + Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(item.FileName);
                                p.Online      = true;
                                p.SortOrder   = 9999;
                                p.Language    = lang;
                                p.TimeCreated = DateTime.Now;
                                p.Title       = "Emlak";
                                PhotoManager.Save(p);
                            }
                        }

                        return(RedirectToAction("Index", "Estate"));
                    }
                    else
                    {
                        ViewBag.ProcessMessage = false;
                        return(View(record));
                    }
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Beispiel #21
0
        public ActionResult EditReference(References referencemodel, HttpPostedFileBase uploadfile, IEnumerable <HttpPostedFileBase> attachments, string language)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            int ID = Convert.ToInt32(RouteData.Values["id"]);

            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    referencemodel.Logo = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                //if (uploadfile != null && uploadfile.ContentLength > 0)
                //{
                //    Random random = new Random();
                //    int rand = random.Next(1000, 99999999);
                //    new ImageHelper(240, 240).SaveThumbnail(uploadfile, "/Content/images/references/", Utility.SetPagePlug(referencemodel.ReferenceName) + "_" + rand + Path.GetExtension(uploadfile.FileName));
                //    referencemodel.Logo = "/Content/images/references/" + Utility.SetPagePlug(referencemodel.ReferenceName) + "_" + rand + Path.GetExtension(uploadfile.FileName);
                //}

                //foreach (var item in attachments)
                //{
                //    if (item != null && item.ContentLength > 0)
                //    {
                //        item.SaveAs(Server.MapPath("/Content/images/userfiles/") + item.FileName);
                //        Random random = new Random();
                //        int rand = random.Next(1000, 99999999);
                //        string path = Utility.SetPagePlug(referencemodel.ReferenceName) + "_" + rand + Path.GetExtension(item.FileName);
                //        new ImageHelper(1020, 768).SaveThumbnail(item, "/Content/images/userfiles/", path);

                //        rand = random.Next(1000, 99999999);
                //        string thumbnail = Utility.SetPagePlug(referencemodel.ReferenceName) + "_" + rand + Path.GetExtension(item.FileName);

                //        // Image img = Image.FromFile(Server.MapPath("/Content/images/userfiles/") + item.FileName);

                //        Bitmap bmp = new Bitmap(Server.MapPath("/Content/images/userfiles/") + item.FileName);

                //        Bitmap bmp2 = new Bitmap(bmp);

                //        using (Bitmap Orgbmp = bmp2)
                //        {

                //            int sabit = 90;
                //            Size Boyut = new Size(210, 125);
                //            Bitmap ReSizedThmb = new Bitmap(Orgbmp, Boyut);
                //            ReSizedThmb.Save(Server.MapPath("/Content/images/userfiles/") + thumbnail);
                //            bmp.Dispose();
                //            bmp2.Dispose();
                //            Orgbmp.Dispose();
                //            GC.Collect();
                //        }

                //        //new ImageHelper(300, 280).ResizeFromStream("/Content/images/userfiles/",thumbnail,img);
                //        Photo p = new Photo();
                //        p.CategoryId = (int)PhotoType.Reference;
                //        p.ItemId = ID;
                //        p.Path = "/Content/images/userfiles/" + path;
                //        p.Thumbnail = "/Content/images/userfiles/" + thumbnail;
                //        p.Online = true;
                //        p.SortOrder = 9999;
                //        p.Language = language;
                //        p.TimeCreated = DateTime.Now;
                //        p.Title = "Haberler";
                //        PhotoManager.Save(p);
                //    }
                //}



                if (RouteData.Values["id"] != null)
                {
                    int  nid      = 0;
                    bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                    if (isnumber)
                    {
                        referencemodel.Language    = language;
                        referencemodel.ReferenceId = nid;
                        ViewBag.ProcessMessage     = ReferenceManager.EditReference(referencemodel);
                        var photos = PhotoManager.GetList(4, ID);
                        ViewBag.Photos = photos;
                        return(View(referencemodel));
                    }
                    else
                    {
                        ViewBag.ProcessMessage = false;
                        return(View(referencemodel));
                    }
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }

            return(View());
        }
Beispiel #22
0
        public ActionResult Edit(Photo Photomodel, HttpPostedFileBase uploadfile, string language)
        {
            var languages = LanguageManager.GetLanguages();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;

            if (ModelState.IsValid)
            {
                //if (uploadfile != null && uploadfile.ContentLength > 0)
                //{
                //    using (System.Drawing.Image image = System.Drawing.Image.FromStream(uploadfile.InputStream, true, true))
                //    {
                //        if (image.Width == 1440 && image.Height == 450)
                //        {
                //            Random random = new Random();
                //            int rand = random.Next(1000, 99999999);
                //            new ImageHelper(1440, 1440).SaveThumbnail(uploadfile, "/Content/images/Photos/", Utility.SetPagePlug("banner") + "_" + rand + Path.GetExtension(uploadfile.FileName));
                //            Photomodel.Path = "/Content/images/Photos/" + Utility.SetPagePlug("banner") + "_" + rand + Path.GetExtension(uploadfile.FileName);
                //            TempData["ImageSizeError"] = null;
                //        }
                //        else
                //        {
                //            TempData["ImageSizeError"] = "Eklemiş olduğunuz resmin boyutları 1440x450 olmalıdır...";
                //            return View();
                //        }
                //    }
                //}

                if (Session["ModifiedImageId"] != null)
                {
                    Photomodel.Path = "/Content/images/userfiles/news/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }

                if (RouteData.Values["id"] != null)
                {
                    int  nid      = 0;
                    bool isnumber = int.TryParse(RouteData.Values["id"].ToString(), out nid);
                    if (isnumber)
                    {
                        Photomodel.PhotoId     = nid;
                        ViewBag.ProcessMessage = PhotoManager.Edit(nid, Photomodel.Title, Photomodel.Path, Photomodel.Link, language);
                        return(View(Photomodel));
                    }
                    else
                    {
                        ViewBag.ProcessMessage = false;
                        return(View(Photomodel));
                    }
                }
                else
                {
                    return(View());
                }
            }
            else
            {
                return(View());
            }
        }
Beispiel #23
0
        public ActionResult Add(Estate record, HttpPostedFileBase uploadfile, IEnumerable <HttpPostedFileBase> attachments, HttpPostedFileBase fileDosya)
        {
            var languages = LanguageManager.GetLanguages();
            //string lang = "";
            //if (RouteData.Values["lang"] == null)
            //    lang = "tr";
            //else lang = RouteData.Values["lang"].ToString();
            //lang =
            var countries = EstateManager.GetCountryList();
            var list      = new SelectList(languages, "Culture", "Language");

            ViewBag.LanguageList = list;
            var countrylist = new SelectList(countries, "Id", "Name");

            ViewBag.Country = countrylist;
            if (ModelState.IsValid)
            {
                if (Session["ModifiedImageId"] != null)
                {
                    record.Photo = "/Content/images/userfiles/" + Session["ModifiedImageId"].ToString() + Session["WorkingImageExtension"].ToString();
                    ImageHelperNew.DestroyImageCashAndSession(0, 0);
                }
                else
                {
                    record.Photo = "/Content/images/front/noimage.jpeg";
                }

                if (fileDosya != null)
                {
                    fileDosya.SaveAs(Server.MapPath("/Content/images/estates/") + fileDosya.FileName);
                    record.EmlakDosyasi = "/Content/images/estates/" + fileDosya.FileName;
                }

                ViewBag.ProcessMessage = EstateManager.AddEstate(record);
                Session.Remove("UploadType");
                foreach (var item in attachments)
                {
                    if (item != null && item.ContentLength > 0)
                    {
                        Random random = new Random();
                        int    rand   = random.Next(1000, 99999999);
                        new ImageHelper(1024, 768).SaveThumbnail(item, "/Content/images/userfiles/", Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(item.FileName));
                        Photo p = new Photo();
                        p.CategoryId = (int)PhotoType.Estate;
                        p.ItemId     = record.Id;
                        p.Path       = "/Content/images/userfiles/" + Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(item.FileName);
                        p.Thumbnail  = "/Content/images/userfiles/" + Utility.SetPagePlug(record.Header) + "_" + rand + Path.GetExtension(item.FileName);
                        p.Online     = true;
                        p.SortOrder  = 9999;

                        p.Language    = record.Language;
                        p.TimeCreated = DateTime.Now;
                        p.Title       = record.Header;
                        PhotoManager.Save(p);
                    }
                }

                ModelState.Clear();
                return(View());
            }
            else
            {
                return(View());
            }
        }