コード例 #1
0
        public ActionResult nasilCalisirResimEkle()
        {
            howIsWorkPicture work = new howIsWorkPicture();

            work.howIsWorkId = settings.how;
            return(View(work));
        }
コード例 #2
0
        public ActionResult nasilCalisirResimGuncelle(howIsWorkPicture pic, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                howIsWorkPicture changePicture = _picture.getOne(pic.id);
                if (changePicture != null)
                {
                    if (file != null)
                    {
                        if (System.IO.File.Exists(Server.MapPath(changePicture.picturePath)))
                        {
                            System.IO.File.Delete(Server.MapPath(changePicture.picturePath));
                        }
                        int    picWidth   = settings.howIsWorkPicture.Width;
                        int    pichHeight = settings.howIsWorkPicture.Height;
                        string newName    = "";
                        if (file.FileName.Length > 10)
                        {
                            newName = Path.GetFileNameWithoutExtension(file.FileName.Substring(0, 10)) + Guid.NewGuid() + Path.GetExtension(file.FileName);
                        }
                        else
                        {
                            newName = Path.GetFileNameWithoutExtension(file.FileName) + "-" + Guid.NewGuid() + Path.GetExtension(file.FileName);
                        }
                        Image  orjResim    = Image.FromStream(file.InputStream);
                        Bitmap pictureDraw = new Bitmap(orjResim, picWidth, pichHeight);
                        if (Directory.Exists(Server.MapPath("/images/howIsWorkPicture")))
                        {
                            pictureDraw.Save(Server.MapPath("/images/howIsWorkPicture/" + newName));
                        }


                        changePicture.picturePath = "/images/howIsWorkPicture/" + newName;
                        changePicture.pictureAlt  = file.FileName;
                        changePicture.pictureText = pic.pictureText;
                        changePicture.stepText    = pic.stepText;

                        _picture.update(changePicture);
                        Session["bannerEklenemedi"] = "Resim Başarıyla Güncellendi";
                        return(RedirectToAction("nasilCalisirResim", new { area = "AdminPanel" }));
                    }
                    else
                    {
                        Session["bannerEklenemedi"] = "Lütfen Güncellemek İstediğiniz Resmi Ekleyiniz";
                    }
                    return(View("nasilCalisirResimGuncelle", pic));
                }
                else
                {
                    Session["bannerEklenemedi"] = "Değiştirilmek İstenilen Resim Bulunamadı !";
                }
                return(View("nasilCalisirResimGuncelle", pic));
            }
            else
            {
                return(View("nasilCalisirResimGuncelle", pic));
            }
        }
コード例 #3
0
        public ActionResult nasilCalisirResimSil(int id)
        {
            howIsWorkPicture isExist = _picture.getOne(id);

            if (isExist != null)
            {
                if (System.IO.File.Exists(Server.MapPath(isExist.picturePath)))
                {
                    System.IO.File.Delete(Server.MapPath(isExist.picturePath));
                }
                _picture.delete(isExist);
                return(Json(new { id = 1, message = "Resim Başarıyla Silindi!" }));
            }
            else
            {
                return(Json(new { id = 0, message = "Resim Silinemedi, Lütfen Tekrar Deneyiniz!" }));
            }
        }
コード例 #4
0
        public ActionResult nasilCalisirResimEkle(howIsWorkPicture picture, HttpPostedFileBase file)
        {
            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    int    picWidth   = settings.howIsWorkPicture.Width;
                    int    pichHeight = settings.howIsWorkPicture.Height;
                    string newName    = "";
                    if (file.FileName.Length > 10)
                    {
                        newName = Path.GetFileNameWithoutExtension(file.FileName.Substring(0, 10)) + Guid.NewGuid() + Path.GetExtension(file.FileName);
                    }
                    else
                    {
                        newName = Path.GetFileNameWithoutExtension(file.FileName) + "-" + Guid.NewGuid() + Path.GetExtension(file.FileName);
                    }
                    Image  orjResim    = Image.FromStream(file.InputStream);
                    Bitmap pictureDraw = new Bitmap(orjResim, picWidth, pichHeight);
                    if (Directory.Exists(Server.MapPath("/images/howIsWorkPicture")))
                    {
                        pictureDraw.Save(Server.MapPath("/images/howIsWorkPicture/" + newName));
                    }


                    picture.picturePath = "/images/howIsWorkPicture/" + newName;
                    picture.pictureAlt  = file.FileName;


                    _picture.add(picture);
                    Session["bannerEklenemedi"] = "Resim Başarıyla Eklendi";
                    return(RedirectToAction("nasilCalisirResim", new { area = "AdminPanel" }));
                }
                else
                {
                    Session["bannerEklenemedi"] = "Lütfen Eklemek İstediğiniz Resmi Ekleyiniz";
                }
                return(View("nasilCalisirResimEkle", picture));
            }
            else
            {
                return(View("nasilCalisirResimEkle", picture));
            }
        }
コード例 #5
0
 public bool update(howIsWorkPicture howIsWorkPicture)
 {
     return(_howIsWorkPictureDal.Update(howIsWorkPicture));
 }
コード例 #6
0
 public bool delete(howIsWorkPicture howIsWorkPicture)
 {
     return(_howIsWorkPictureDal.Delete(_howIsWorkPictureDal.getOne(x => x.id == howIsWorkPicture.id)));
 }
コード例 #7
0
 public bool add(howIsWorkPicture howIsWorkPicture)
 {
     return(_howIsWorkPictureDal.Add(howIsWorkPicture));
 }