Ejemplo n.º 1
0
        public ActionResult ManageLevel(ManageLevel model)
        {
            try
            {
                var LevelName        = model.LevelName.Trim();
                var LevelDescription = model.LevelDescription.Trim();

                var temp = db.ActivityLevels.Where(r => r.ActivityLevel1 == LevelName && r.IsActive == true).Select(f => f.ActivityLevel1);

                foreach (var check in temp)
                {
                    if (check == LevelName)
                    {
                        return(Json("Warning", JsonRequestBehavior.AllowGet));
                    }
                }

                {
                    var Assignobj = db.ActivityLevels.CreateObject();
                    Assignobj.ActivityLevel1   = LevelName;
                    Assignobj.LevelDescription = LevelDescription;
                    db.ActivityLevels.AddObject(Assignobj);
                    db.SaveChanges();
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        public ActionResult AddLevel(ManageLevel model)
        {
            try
            {
                var LevelName        = model.LevelName.Trim();
                var LevelDescription = "";
                if (model.LevelDescription != null)
                {
                    LevelDescription = model.LevelDescription.Trim();
                }
                var temp = db.ActivityLevels.Where(r => r.ActivityLevel1 == LevelName && r.IsActive == true).Select(f => f.ActivityLevelID).FirstOrDefault();

                //foreach (var check in temp)
                //{

                if (temp != 0)
                {
                    return(Json("Warning", JsonRequestBehavior.AllowGet));
                }


                //}

                {
                    var count     = db.ActivityLevels.Where(x => x.IsActive == true).Select(o => o).Count();
                    var Assignobj = db.ActivityLevels.CreateObject();
                    Assignobj.ActivityLevel1   = LevelName;
                    Assignobj.IsActive         = true;
                    Assignobj.LevelDescription = LevelDescription;
                    Assignobj.LevelOrder       = count + 1;
                    db.ActivityLevels.AddObject(Assignobj);
                    db.SaveChanges();
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(Json("Success", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 3
0
        public ActionResult EditLevel(ManageLevel Model)
        {
            try
            {
                DSRCManagementSystemEntities1 db = new DSRCManagementSystemEntities1();
                int    LevelId          = Model.LevelId;
                string LevelName        = Model.LevelName.Trim();
                string LevelDescription = "";
                if (Model.LevelDescription != null)
                {
                    LevelDescription = Model.LevelDescription.Trim();
                }
                var data = db.ActivityLevels.Where(o => o.ActivityLevelID != LevelId && o.IsActive == true).Select(o => o.ActivityLevel1);

                foreach (var check in data)
                {
                    if (check.ToLower() == LevelName.ToLower())
                    {
                        return(Json("Warning", JsonRequestBehavior.AllowGet));
                    }
                }
                var datas = db.ActivityLevels.Where(o => o.ActivityLevelID == LevelId).Select(o => o).FirstOrDefault();
                {
                    datas.ActivityLevel1   = LevelName;
                    datas.LevelDescription = LevelDescription;
                    db.SaveChanges();
                }
            }
            catch (Exception Ex)
            {
                string actionName     = this.ControllerContext.RouteData.Values["action"].ToString();
                string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString();
                ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName);
            }
            return(Json("Success1", JsonRequestBehavior.AllowGet));
        }