Exemplo n.º 1
0
 public ActionResult Destroy([DataSourceRequest] DataSourceRequest request, SystemRuleVM viewModel)
 {
     try
     {
         if (viewModel != null)
         {
             ModelState.Clear();
             SystemRule delviewModel = db.SystemRules.Find(viewModel.SystemRuleId);
             if (delviewModel != null)
             {
                 db.SystemRules.Remove(delviewModel);
                 db.SaveChanges();
             }
         }
     }
     catch (DbUpdateException dbUpdEx)
     {
         ModelState.AddModelError("showerror", "Delete failed.  This is most likely due to related child information that needs to be deleted first.");
         Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Delete failed.  This is most likely due to related child information that needs to be deleted first."));
         Elmah.ErrorSignal.FromCurrentContext().Raise(dbUpdEx);
     }
     catch (DataException dataEx)
     {
         ModelState.AddModelError("hideerror", "Data error");
         Elmah.ErrorSignal.FromCurrentContext().Raise(dataEx);
     }
     return Json(ModelState.IsValid ? new object() : ModelState.ToDataSourceResult());
 }
Exemplo n.º 2
0
        public JsonResult AvailableSystemsListing([DataSourceRequest]DataSourceRequest request, bool AddDefault = false)
        {
            IQueryable<SystemRule> tObj = null;
            int iUserId = ((UserSessionVM)HttpContext.Session["UserSession"]).UserId;
            tObj = db.SystemRules.Where( w => w.Campaigns.Any(wc => wc.UserUserId == iUserId)).OrderBy(o => o.SystemName);
            List<SystemRuleVM> resultList = new List<SystemRuleVM>();
            SystemRuleVM firstItem = new SystemRuleVM();
            if (AddDefault)
            {
                firstItem.SystemRuleId = -1;
                firstItem.SystemName = "None";
                resultList.Add(firstItem);
            }
            foreach (var item in tObj)
            {
                SystemRuleVM newItem = new SystemRuleVM();
                newItem.SystemRuleId = item.SystemRuleId;
                newItem.SystemName = item.SystemName;
                resultList.Add(newItem);
            }

            return Json(resultList, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 3
0
        public ActionResult Create([DataSourceRequest] DataSourceRequest request, SystemRuleVM viewModel)
        {
            try
            {
                if (viewModel != null && ModelState.IsValid)
                {
                    SystemRule newviewModel = new SystemRule();

                    newviewModel.SystemName = viewModel.SystemName;
                    newviewModel.Description = viewModel.Description;

                    db.SystemRules.Add(newviewModel);
                    db.SaveChanges();
                    viewModel.SystemRuleId = newviewModel.SystemRuleId;
                }
            }
            catch (DataException dataEx)
            {
                ModelState.AddModelError(string.Empty, "Data error");
                Elmah.ErrorSignal.FromCurrentContext().Raise(dataEx);
            }

            return Json(new[] { viewModel }.ToDataSourceResult(request, ModelState));
        }
Exemplo n.º 4
0
        public JsonResult SystemsListing([DataSourceRequest]DataSourceRequest request, bool AddDefault = false)
        {
            IQueryable<SystemRule> tObj = null;
            tObj = db.SystemRules.OrderBy(o => o.SystemName);
            List<SystemRuleVM> resultList = new List<SystemRuleVM>();
            SystemRuleVM firstItem = new SystemRuleVM();
            if (AddDefault)
            {
                firstItem.SystemRuleId = -1;
                firstItem.SystemName = "None";
                resultList.Add(firstItem);
            }
            foreach (var item in tObj)
            {
                SystemRuleVM newItem = new SystemRuleVM();
                newItem.SystemRuleId = item.SystemRuleId;
                newItem.SystemName = item.SystemName;
                resultList.Add(newItem);
            }

            return Json(resultList, JsonRequestBehavior.AllowGet);
        }