Beispiel #1
0
        public ActionResult Edit([FromBody] ServiceTemplateTreeModel model)
        {
            //validation

            var result = db.ServiceTemplateTrees.Where(x => x.ServiceTemplateTreeId == model.ServiceTemplateTreeId).FirstOrDefault();

            if (result == null)
            {
                return(BadRequest());
            }
            //result = model;
            result.Title = model.Title;
            result.ReginalPowerCorpRef    = model.ReginalPowerCorpRef;
            result.ServiceTemplateTreeRef = model.ServiceTemplateTreeRef;
            result.Level = model.Level;

            result.Code        = model.Code;
            result.State       = model.State;
            result.Description = model.Description;

            db.Update(result);
            db.SaveChanges();

            //db.Entry(model).State = EntityState.Modified;
            //var affectedRow = db.SaveChanges();

            return(Ok());
        }
Beispiel #2
0
        public ActionResult CreateAsChild(int id, string level)
        {
            //var result = AllItems.Where(x => x.ProjectTreeId == id).Select( s=>new { s.Title ,s.ReginalPowerCorpRef,s.ProjectTreeRef, ReginalPowerCorpTitle=s.ReginalPowerCorp.Title, ProjectParent=s.ProjectTree.Title,s.LevelCode,s.Code,s.IsTemplate,s.State});
            new ServiceTemplateTreeModel();
            var result = new ServiceTemplateTreeModel {
                ServiceTemplateTreeRef = id, Level = level
            };


            return(Ok(result));
        }
Beispiel #3
0
        public ActionResult Delete([FromBody] ServiceTemplateTreeModel model)
        {
            //validation
            var result = AllItems.Where(x => x.ServiceTemplateTreeId == model.ServiceTemplateTreeId).FirstOrDefault();

            if (result == null)
            {
                return(BadRequest());
            }
            db.Remove(result);
            db.SaveChanges();
            return(Ok());
        }
Beispiel #4
0
        public ActionResult Create([FromBody] ServiceTemplateTreeModel model)
        {
            //validation


            if (ModelState.IsValid)
            {
                model.LevelCode = model.LevelCode + "-" + model.Level;
                if (model.ServiceTemplateTreeRef == 0)
                {
                    model.ServiceTemplateTreeRef = null;
                }
                db.Add(model);
                db.SaveChanges();
                // Thread.Sleep(100);
            }
            return(Ok());
        }