Пример #1
0
 public ActionResult AddOrEdit(BKRY_CATEGORY bkt, HttpPostedFileBase file)
 {
     try
     {
         byte[] buf = null;
         if (file != null && file.ContentLength > 0)
         {
             buf = new byte[file.ContentLength];
             file.InputStream.Read(buf, 0, buf.Length);
             bkt.image = buf;
         }
         bkt.insert_by = Session != null && Session["UserName"] != null ? Session["UserName"].ToString() : "";
         bkt.add_date  = DateTime.Now;
         using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
         {
             if (bkt.Id == 0)
             {
                 db.BKRY_CATEGORY.Add(bkt);
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 db.Entry(bkt).State = EntityState.Modified;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex) {
         Console.WriteLine(ex.ToString());
     }
     return(null);
 }
Пример #2
0
 public ActionResult Delete(int id)
 {
     using (BKRY_MNGT_SYSEntities db = new BKRY_MNGT_SYSEntities())
     {
         BKRY_CATEGORY emp = db.BKRY_CATEGORY.Where(x => x.Id == id).FirstOrDefault <BKRY_CATEGORY>();
         db.BKRY_CATEGORY.Remove(emp);
         db.SaveChanges();
         return(Json(new { success = true, message = "Deleted Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Пример #3
0
        public ActionResult getImage(int id)
        {
            BKRY_CATEGORY obj = null;

            obj = db.BKRY_CATEGORY.Where(x => x.Id == id).ToList().FirstOrDefault();
            if (obj == null || obj.image == null)
            {
                return(null);
            }
            return(File(obj.image, "image/jpeg")); // Might need to adjust the content type based on your actual image type
        }