Beispiel #1
0
 public NameSpaceGridModel(NameSpace ns)
 {
     Id = ns.Id;
     NameSpaceName = ns.NameSpaceName;
     Description = ns.Description;
 }
 public ActionResult SaveNameSpace([FromURLEncodedJson]NameSpaceGridModel nameSpace)
 {
     if (nameSpace.Id == 0)
     {
         var ns = new NameSpace();
         ns.Description = nameSpace.Description;
         ns.NameSpaceName = nameSpace.NameSpaceName;
         using (var db = new ContentRepository())
         {
             db.NameSpaces.Add(ns);
             db.SaveChanges();
             db.Commit();
         }
     }
     else
     {
         using (var db = new ContentRepository())
         {
             var nameSpaceQry = from n in db.NameSpaces where n.Id == nameSpace.Id select n;
             if (nameSpaceQry.Any())
             {
                 var ns = nameSpaceQry.First();
                 ns.Description = nameSpace.Description;
                 ns.NameSpaceName = nameSpace.NameSpaceName;
                 db.SaveChanges();
                 db.Commit();
             }
         }
     }
     return View("Index");
 }