Exemple #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         SliderManager SM     = new SliderManager();
         SliderTBx     slider = new SliderTBx();
         slider.Status    = 1;
         slider.Title     = Request["title"];
         slider.ShortDesc = Request.Unvalidated["shortDesc"];
         SM.AddNew(slider);
         slider.URL = "/upload/slider/slider_" + slider.ID + ".jpg";
         SM.Save();
         string       base64     = Request["base64"];
         byte[]       imageBytes = Convert.FromBase64String(base64);
         MemoryStream ms         = new MemoryStream(imageBytes, 0, imageBytes.Length);
         ms.Write(imageBytes, 0, imageBytes.Length);
         System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
         string fileName            = "slider_" + slider.ID + ".jpg";
         image.Save(Path.Combine(Server.MapPath("~/upload/slider"), fileName));
         Response.Write(JsonConvert.SerializeObject(new
         {
             success = 1
         }));
     }
     catch (Exception ex)
     {
         Response.Write(JsonConvert.SerializeObject(new
         {
             success = -1,
             error   = ex
         }));
     }
 }
Exemple #2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         SliderManager SM     = new SliderManager();
         int           ID     = Convert.ToInt32(Request["ID"]);
         SliderTBx     slider = SM.GetByID(ID);
         slider.Status = -1;
         SM.Save();
         Response.Write(JsonConvert.SerializeObject(new
         {
             success = 1
         }));
     }
     catch (Exception ex)
     {
         Response.Write(JsonConvert.SerializeObject(new
         {
             success = -1,
             error   = ex
         }));
     }
 }