Example #1
0
 public bool InsertSlider(mSlider pSliders)
 {
     try
     {
         tbl_slider vSlider = new tbl_slider();
         var        query   = from b in Db.tbl_slider
                              orderby b.slider_id descending
                              select b;
         vSlider = query.FirstOrDefault();
         tbl_slider s = new tbl_slider();
         s.slider_link    = pSliders.slider_link;
         s.slider_img     = pSliders.slider_img;
         s.slider_sort    = pSliders.slider_sort;
         s.slider_exp     = pSliders.slider_exp;
         s.slider_title   = pSliders.slider_title;
         s.slider_id      = vSlider.slider_id + 1;
         s.slider_img_alt = pSliders.slider_img_alt;
         Db.tbl_slider.Add(s);
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #2
0
        //public static bool saveSlide(tbl_slider _Slider)
        //{
        //    bool _result = true;
        //    using (seckinkirtasiyeEntities db = new seckinkirtasiyeEntities())
        //    {
        //        try
        //        {
        //            if (_Slider.Slider_image_ID == 0)
        //            {
        //                db.tbl_slider.Add(_Slider);
        //            }
        //            else
        //            {
        //                db.tbl_slider.Attach(_Slider);
        //                db.Entry(_Slider).State = System.Data.Entity.EntityState.Modified;
        //            }
        //            db.SaveChanges();
        //        }
        //        catch (Exception)
        //        {
        //            _result = false;

        //        }
        //    }

        //    return _result;

        //}



        public static bool saveSlide(tbl_slider _Slider)
        {
            bool _result = true;

            using (seckinkirtasiyeEntities db = new seckinkirtasiyeEntities())
            {
                try
                {
                    if (_Slider.Slider_image_ID == 0)
                    {
                        db.tbl_slider.Add(_Slider);
                    }
                    else
                    {
                        db.tbl_slider.Attach(_Slider);
                        db.Entry(_Slider).State = System.Data.Entity.EntityState.Modified;
                    }
                    db.SaveChanges();
                }
                catch (Exception)
                {
                    _result = false;
                }
            }

            return(_result);
        }
Example #3
0
        public ActionResult Slide_Delete(int slide_id)
        {
            tbl_slider _deleteslide = (from p in db.tbl_slider where p.Slider_image_ID == slide_id select p).SingleOrDefault();
            int        proid        = _deleteslide.Slider_image_ID;

            db.tbl_slider.Remove(_deleteslide);
            db.SaveChanges();
            return(RedirectToAction("Slider", "Admin"));
        }
Example #4
0
 public bool fUpdateSlider(mSlider pSliders)
 {
     try
     {
         tbl_slider s = new tbl_slider();
         s.slider_id      = pSliders.slider_id;
         s.slider_link    = pSliders.slider_link;
         s.slider_img     = pSliders.slider_img;
         s.slider_sort    = pSliders.slider_sort;
         s.slider_exp     = pSliders.slider_exp;
         s.slider_title   = pSliders.slider_title;
         s.slider_img_alt = pSliders.slider_img_alt;
         Db.tbl_slider.Attach(s);
         Db.Entry(s).State = System.Data.Entity.EntityState.Modified;
         return(Convert.ToBoolean(Db.SaveChanges()));
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #5
0
        public ActionResult Slider(int?id)
        {
            if (Session["UserID"] == null)
            {
                return(RedirectToAction("Login", "Admin"));
            }

            if (RouteData.Values["id"] != null)
            {
                ViewBag.UpdateSlide = "True";
                int        _id    = Convert.ToInt32(RouteData.Values["id"]);
                tbl_slider _slide = Data.Data.get_slide(id);
                ViewBag.Slide_Image = _slide.Slider_image;
                ViewBag.Slide_Title = _slide.Slider_image_title;
                ViewBag.Slide_Text  = _slide.Slider_image_text;


                return(View(_slide));
            }

            return(View());
        }
Example #6
0
        public ActionResult Slider(HttpPostedFileBase input_slider, tbl_slider _Slider, HttpPostedFileBase input_slider_null)
        {
            if (input_slider != null && input_slider.ContentLength > 0)
            {
                string File    = System.IO.Path.GetFileName(input_slider.FileName);
                string GuidKey = Guid.NewGuid().ToString();
                string fileExt = Path.GetExtension(input_slider.FileName);
                _Slider.Slider_image = GuidKey + fileExt;

                var uploadurl      = ftp;
                var uploadfilename = GuidKey + fileExt;

                Stream streamObj = input_slider.InputStream;
                byte[] buffer    = new byte[input_slider.ContentLength];
                streamObj.Read(buffer, 0, buffer.Length);
                streamObj.Close();
                streamObj = null;
                string ftpurl     = String.Format("{0}/{1}", uploadurl, uploadfilename);
                var    requestObj = FtpWebRequest.Create(ftpurl) as FtpWebRequest;
                requestObj.Method      = WebRequestMethods.Ftp.UploadFile;
                requestObj.Credentials = new NetworkCredential(ftpuser, pasword);
                Stream requestStream = requestObj.GetRequestStream();
                requestStream.Write(buffer, 0, buffer.Length);
                requestStream.Flush();
                requestStream.Close();
                requestObj = null;
            }
            else if (input_slider_null != null && input_slider_null.ContentLength > 0)
            {
                string File    = System.IO.Path.GetFileName(input_slider_null.FileName);
                string GuidKey = Guid.NewGuid().ToString();
                string fileExt = Path.GetExtension(input_slider_null.FileName);
                _Slider.Slider_image = GuidKey + fileExt;

                var uploadurl      = ftp;
                var uploadfilename = GuidKey + fileExt;

                Stream streamObj = input_slider_null.InputStream;
                byte[] buffer    = new byte[input_slider_null.ContentLength];
                streamObj.Read(buffer, 0, buffer.Length);
                streamObj.Close();
                streamObj = null;
                string ftpurl     = String.Format("{0}/{1}", uploadurl, uploadfilename);
                var    requestObj = FtpWebRequest.Create(ftpurl) as FtpWebRequest;
                requestObj.Method      = WebRequestMethods.Ftp.UploadFile;
                requestObj.Credentials = new NetworkCredential(ftpuser, pasword);
                Stream requestStream = requestObj.GetRequestStream();
                requestStream.Write(buffer, 0, buffer.Length);
                requestStream.Flush();
                requestStream.Close();
                requestObj = null;
            }


            if (Data.Data.saveSlide(_Slider) == false)
            {
                ViewBag.Error = "Lütfen Bilgilerinizi Kontrol Ediniz.";
                return(RedirectToAction("Error", "Default"));
            }
            return(RedirectToAction("Slider", "Admin"));
        }