protected void Page_Load(object sender, EventArgs e) { if (Session["Admin_Id"] != null) { string aa = Request["id"]; ad_LogicUploader lu = new ad_LogicUploader(); int res = lu.DeleteImage(aa); if (res == 1) { Response.Write("عکس با موفقیت حذف شد"); } else if (res == -1) { Response.Write("عکس یافت نشد احتمالا در همین هنگام شخص دیگری آنرا حذف کرده است"); } else if (res == -2) { Response.Write("عکس با موفقیت حذف شد"); } else if (res == -3) { Response.Write("عدم توانایی در حذف تصویر با پشتیبانی تماس حاصل فرمایید"); } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["Admin_Id"] != null) { var logic = new ad_LogicUploader(); List <PicModel> model = logic.loadGallery(); Response.Write(JsonConvert.SerializeObject(model)); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //try //{ PersianDateTime PDT = new PersianDateTime(DateTime.Now); string AbsolutePath = HttpContext.Current.Server.MapPath(Path.Combine($"~/uploads/{PDT.Year}/{PDT.Month}/{PDT.Day}")); if (!Directory.Exists(AbsolutePath)) { Directory.CreateDirectory(AbsolutePath); } string name = context.Request.Form["name"]; string lable = context.Request["lable"]; string desc = context.Request["desc"]; string webFileAddress = ""; foreach (string s in context.Request.Files) { HttpPostedFile file = context.Request.Files[s]; string fileName = file.FileName; string fileExtension = file.ContentType; if (!string.IsNullOrEmpty(fileName)) { string EX = Path.GetExtension(file.FileName); string FileNAME = name.Replace(" ", "-") + DateTime.Now.Ticks.ToString() + EX; string address = HttpContext.Current.Server.MapPath(Path.Combine($"~/uploads/{PDT.Year}/{PDT.Month}/{PDT.Day}", FileNAME)); webFileAddress = $"/uploads/{PDT.Year}/{PDT.Month}/{PDT.Day}/{FileNAME}"; AbsolutePath = address; file.SaveAs(address); } } ad_LogicUploader up = new ad_LogicUploader(); bool stat = up.saveIMG(name, lable, desc, webFileAddress, AbsolutePath); if (stat) { context.Response.Write("با موفقیت ثبت شد!"); } else { context.Response.Write("عدم توانایی در ثبت عکس با پشتیبانی تماس حاصل فرمایید!"); } // database record update logic here () //} //catch (Exception ac) //{ //} }
protected void Page_Load(object sender, EventArgs e) { if (Session["Admin_Id"] != null) { string aa = Request["id"]; string name = Request["name"]; string lable = Request["lable"]; string desc = Request["desc"]; ad_LogicUploader lu = new ad_LogicUploader(); bool res = lu.UpdateImageInformation(aa, name, lable, desc); if (res) { Response.Write("عکس با موفقیت ویرایش شد"); } else { Response.Write("عدم توانایی در ویرایش تصویر با پشتیبانی تماس حاصل فرمایید"); } } }