예제 #1
0
 /// <summary>
 ///     Creates a new UserRole.
 /// </summary>
 /// <param name="role"></param>
 public void Create(UserRole role)
 {
     ThrowIfNull(role);
     role.IsEditable = true;
     ValidateAndThrow(role, _userRoleValidator);
     Context.UserRoles.Add(role);
     Context.SaveChanges();
 }
예제 #2
0
        /// <summary>
        ///     Updates a UserRole.
        ///     Makes sure the db version is editable.
        /// </summary>
        /// <param name="role"></param>
        public void Update(UserRole role)
        {
            ThrowIfNull(role);
            // only pulling dbRole to make sure it is editable, otherwise could just attach...
            var dbRole = Context.UserRoles.Single(ur => ur.Id == role.Id);

            dbRole.Name        = role.Name;
            dbRole.Description = role.Description;
            ValidateAndThrow(dbRole, _userRoleValidator); // ensures editable
            Context.SetEntityState(dbRole, EntityState.Modified);
            Context.SaveChanges();
        }
예제 #3
0
        public ActionResult Add(UserRole model)
        {
            Utility.ReturnData<string> returnData = new Utility.ReturnData<string>();
            model.Addtime = DateTime.Now;
            model.AddUserBasicID = LoginUser.UserBasicID;
            model.EnterpriseID = LoginUser.UserBasic.EnterpriseID;
            returnData = bll.AddOrUpdateUserRole(model);
            if (returnData.Message=="添加成功!")
            {
                return Content(returnData.Message);
            }
            else
            {
                return Content(returnData.Message);
            }

        }
예제 #4
0
파일: UserRole.cs 프로젝트: wzcb2009/npsyzx
 public void Add(UserRole pUserRole)
 {
     _arrayInternal.Add(pUserRole);
 }
예제 #5
0
 /// <summary>
 ///     Checks that a UserRole name is unique before saving.
 /// </summary>
 /// <param name="role"></param>
 /// <param name="name"></param>
 /// <returns>Returns a bool indicating uniqueness.</returns>
 public bool BeAUniqueUserRoleName(UserRole role, string name)
 {
     return(!Context.UserRoles.Any(r => r.Name == name && r.Id != role.Id));
 }