Example #1
0
        // GET: AdminPanel/GenderGategories/Delete/5
        public ActionResult Delete(int?id)
        {
            GenderGategory genderGategory = db.GenderGategories.Find(id);

            db.GenderGategories.Remove(genderGategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #2
0
        // GET: AdminPanel/GenderGategories/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            GenderGategory genderGategory = db.GenderGategories.Find(id);

            if (genderGategory == null)
            {
                return(HttpNotFound());
            }
            return(View(genderGategory));
        }
Example #3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Img")] GenderGategory genderGategory, HttpPostedFileBase file1)
 {
     if (ModelState.IsValid)
     {
         if (file1 != null)
         {
             Random rand    = new Random();
             string imgcode = rand.Next(100000, 900000).ToString();
             file1.SaveAs(HttpContext.Server.MapPath("~/images/Banner/") + imgcode.ToString() + "-" + file1.FileName);
             genderGategory.Img = imgcode.ToString() + "-" + file1.FileName;
         }
         db.Entry(genderGategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(genderGategory));
 }