public JsonResult saveAgad(AGAD.Models.AGAD model)
        {
            if (ModelState.IsValid)
            {
                using(var db=new AGAD.Models.agadContext())
                {
                    using (var trans = db.Database.BeginTransaction())
                    {
                        try
                        {
                            if (Session["imagePaths"] != null)
                            {

                                db.AGADs.Add(model);

                               var liste=Session["imagePaths"] as List<string>;
                                foreach(var item in liste)
                                {
                                    db.IMAGEPATHs.Add(new IMAGEPATH
                                    {
                                        AGAD_ID=model.Id,
                                        PATH=item
                                    });

                                }

                            }
                            db.SaveChanges();
                            trans.Commit();
                        }
                        catch (Exception ex)
                        {
                            trans.Rollback();
                            return Json(new { success = false });
                        }
                    }
                }
                return Json(new { success = true });
            }
            else
            {
                return Json(new { success = false });
            }
        }
 public ActionResult getList(int pagination = 0)
 {
     // not show home icon
     ViewBag.homeIcon = false;
     ViewBag.ID = pagination;
     var temp = new List<AGAD.Models.AGAD>();
     var db = new AGAD.Models.agadContext();
     var user = db.USERs.Where(w => w.EMAIL == User.Identity.Name).FirstOrDefault();
     //check user
     if (user != null)
     {
         ViewBag.userName = user.NAME + " " + user.SURNAME;
     }
     // take 5 agads
     var agads = db.AGADs.OrderBy(w => w.STARTDATE).Skip((pagination - 1) * 5).Take(5);
     var countAGAD = db.AGADs.Count();
     //calculate paging parameter
     ViewBag.countAGAD = Math.Ceiling((decimal)countAGAD / 5);
     ViewBag.pagination = pagination;
     return View("~/Views/ADMIN/_getList.cshtml", agads.ToList());
 }
 public ActionResult getDetailAGAD(int detailPage)
 {
     ViewBag.homeIcon = true;
     var db = new AGAD.Models.agadContext();
     var user = db.USERs.Where(w => w.EMAIL == User.Identity.Name).FirstOrDefault();
     if (user != null)
     {
         ViewBag.userName = user.NAME + " " + user.SURNAME;
     }
     ViewBag.confirmState = db.CONFIRMSTATEs.ToList();
     ViewBag.ID = detailPage;
     var model = db.AGADs.Where(w => w.Id == detailPage).FirstOrDefault();
     if (model == null)
     {
         throw new HttpException(404, "Hatalı Öge");
     }
     if(model.CONFIRMSTATEID==(int)CONFIRMSTATEENUM.NOTACCEPTED)
     {
         model.CONFIRMSTATEID = (int)CONFIRMSTATEENUM.PROCESSING;
         db.SaveChanges();
     }
     model.USER_TC = user.TC;
     return View("~/Views/ADMIN/_detailAGAD.cshtml", model);
 }