Inheritance: INotifyPropertyChanging, INotifyPropertyChanged
コード例 #1
0
ファイル: RolesController.cs プロジェクト: Paelyt/Payorboro
        public IHttpActionResult PutRole(int id, DataAccess.Role role)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != role.RoleId)
            {
                return(BadRequest());
            }

            db.Entry(role).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoleExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task<int> UpdateUserRoleAndStatus(CompetentAuthorityUser user, Role role, UserStatus status)
        {
            user.UpdateUserStatus(status.ToDomainEnumeration<Domain.User.UserStatus>());
            user.UpdateRole(role);

            return await context.SaveChangesAsync();
        }
コード例 #3
0
ファイル: RolesController.cs プロジェクト: Paelyt/Payorboro
        public IHttpActionResult GetRole(int id)
        {
            DataAccess.Role role = db.Roles.Find(id);
            if (role == null)
            {
                return(NotFound());
            }

            return(Ok(role));
        }
コード例 #4
0
ファイル: RolesController.cs プロジェクト: Paelyt/Payorboro
        public IHttpActionResult DeleteRole(int id)
        {
            DataAccess.Role role = db.Roles.Find(id);
            if (role == null)
            {
                return(NotFound());
            }

            db.Roles.Remove(role);
            db.SaveChanges();

            return(Ok(role));
        }
コード例 #5
0
ファイル: V1.cs プロジェクト: kuibono/WebApplication1
        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;
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Create a new Role object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 public static Role CreateRole(global::System.Int32 id, global::System.String name)
 {
     Role role = new Role();
     role.Id = id;
     role.Name = name;
     return role;
 }
コード例 #7
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Role EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToRole(Role role)
 {
     base.AddObject("Role", role);
 }
コード例 #8
0
 partial void DeleteRole(Role instance);
コード例 #9
0
 partial void UpdateRole(Role instance);
コード例 #10
0
 partial void InsertRole(Role instance);