Exemplo n.º 1
0
 public ActionResult Edit(Group item)
 {
     try
     {
         DataAccess.Save<Group>(item);
         return RedirectToAction("Index");
     }
     catch
     {
         ViewBag.Places = DataAccess.Query<Place>().ToList();
         return View();
     }
 }
Exemplo n.º 2
0
        public static bool InstallAll()
        {
            using (Model2Container c = new Model2Container())
            {
                Group g = new Group();
                g.Name = "公司";
                c.AddToGroup(g);

                Group g2 = new Group();
                g2.Name = "财务部";
                g2.Parent = g;
                c.AddToGroup(g2);

                Role r = new Role();
                r.Name = "经理";
                c.AddToRole(r);

                Role r2 = new Role();
                r2.Name = "主管";
                c.AddToRole(r2);

                Role r3 = new Role();
                r3.Name = "组长";
                c.AddToRole(r3);

                Role r4 = new Role();
                r4.Name = "员工";
                c.AddToRole(r4);

                User u = new User();
                u.Group = g;
                u.LoginName = "user1";
                u.Name = "总经理1";
                u.Password = "******";
                u.Roles = new EntityCollection<Role>() { r };
                c.AddToUser(u);

                User u1 = new User();
                u1.Group = g2;
                u1.LoginName = "user1";
                u1.Name = "财务主管1";
                u1.Password = "******";
                u1.Roles = new EntityCollection<Role>() { r2 };
                c.AddToUser(u1);

                User u2 = new User();
                u2.Group = g2;
                u2.LoginName = "user1";
                u2.Name = "财务专员";
                u2.Password = "******";
                u2.Roles = new EntityCollection<Role>() { r4 };
                c.AddToUser(u2);

                DataVersion v = new DataVersion();
                v.Version = 1;
                c.AddToDataVersion(v);

                AddWorlFlow();
                try
                {
                    c.SaveChanges();
                    return true;
                }
                catch (Exception)
                {
                    return false;
                }
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Create a new Group object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Group CreateGroup(global::System.Int32 id, global::System.String name)
 {
     Group group = new Group();
     group.Id = id;
     group.Name = name;
     return group;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Group EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGroup(Group group)
 {
     base.AddObject("Group", group);
 }