public ActionResult DeleteConfirmed(int id)
        {
            Service_Area service_Area = db.Service_Area.Find(id);

            db.Service_Area.Remove(service_Area);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "service_id,service_img,service_title,service_content,service_content_url")] Service_Area service_Area)
 {
     if (ModelState.IsValid)
     {
         db.Entry(service_Area).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(service_Area));
 }
        public ActionResult Create([Bind(Include = "service_id,service_title,service_subtitle,service_item_title,service_icon,service_item_subtitle")] Service_Area service_Area)
        {
            if (ModelState.IsValid)
            {
                db.Service_Area.Add(service_Area);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(service_Area));
        }
Esempio n. 4
0
        public ActionResult DeleteConfirmed(int id)
        {
            if (!Check_Admin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            Service_Area service_Area = db.Service_Area.Find(id);

            db.Service_Area.Remove(service_Area);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        // GET: Service_Area/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Service_Area service_Area = db.Service_Area.Find(id);

            if (service_Area == null)
            {
                return(HttpNotFound());
            }
            return(View(service_Area));
        }
Esempio n. 6
0
        public ActionResult Create([Bind(Include = "service_id,service_title,service_content,service_content_url")] Service_Area service_Area, HttpPostedFileBase service_img)
        {
            if (ModelState.IsValid)
            {
                string file_name = DateTime.Now.ToString("MMddyyyyfffttHHssmm") + Path.GetFileName(service_img.FileName);
                string file_path = Path.Combine(Server.MapPath("~/Uploads/"), file_name);
                service_img.SaveAs(file_path);
                service_Area.service_img = file_name;

                db.Service_Area.Add(service_Area);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(service_Area));
        }
        public ActionResult Create([Bind(Include = "service_id,service_img,service_title,service_content,service_content_url")] Service_Area service_Area, HttpPostedFileBase service_img)
        {
            if (ModelState.IsValid)
            {
                var file_name = Path.GetFileName(service_img.FileName);
                if (service_img.ContentLength > 0)
                {
                    var file_src = Path.Combine(Server.MapPath("/Uploads"), file_name);
                    service_img.SaveAs(file_src);
                }
                service_Area.service_img = file_name;
                db.Service_Area.Add(service_Area);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(service_Area));
        }
Esempio n. 8
0
        // GET: Service_Area/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!Check_Admin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Service_Area service_Area = db.Service_Area.Find(id);

            if (service_Area == null)
            {
                return(HttpNotFound());
            }
            return(View(service_Area));
        }
Esempio n. 9
0
        public ActionResult Create([Bind(Include = "service_id,service_title,service_content,service_content_url")] Service_Area service_Area, HttpPostedFileBase service_img)
        {
            if (!AdminPanelMethods.CheckAdminLogin())
            {
                return(RedirectToAction("Index", "Login"));
            }
            if (ModelState.IsValid)
            {
                Random rand       = new Random();
                string photo_name = rand.Next(11111, 99999).ToString() + Path.GetExtension(service_img.FileName);
                string photo_path = Path.Combine(Server.MapPath("/Uploads"), photo_name);
                service_img.SaveAs(photo_path);

                service_Area.service_img = photo_name;
                db.Service_Area.Add(service_Area);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(Content("File not chosen!"));
        }