Esempio n. 1
0
        /// <summary>
        ///     Save the role data of a dynamic role..
        /// </summary>
        /// <param name="data">The role data to save.</param>
        /// <exception cref="DataExistsException">Thrown if the data for a dynamic role already exists.</exception>
        /// <exception cref="DataIncompleteException">Thrown if the data has missing id values.</exception>
        public async Task Save(DynamicRoleData data)
        {
            if (data.RoleId == 0)
            {
                throw new DataIncompleteException("The id of the role is missing.");
            }

            if (data.DynamicRoleId == 0)
            {
                throw new DataIncompleteException("The id of the dynamic role is missing.");
            }

            var roleData = await _dbData.Get(data.RoleId);

            if (roleData != null && roleData.Any(x =>
                                                 x.DynamicRoleId == data.DynamicRoleId ||
                                                 x.DynamicRole.ServerId == data.DynamicRole.ServerId &&
                                                 x.DynamicRole.Status == data.DynamicRole.Status))
            {
                throw new DataExistsException("The role data already exists.");
            }

            data.DynamicRole = null;
            await _dbData.Add(data);
        }
Esempio n. 2
0
        public async Task Remove(DynamicRoleData value)
        {
            var roleData = Context.Entry(value);

            if (roleData == null)
            {
                return;
            }

            Context.DynamicRoleData.Remove(roleData.Entity);
            await Context.SaveChangesAsync();
        }
Esempio n. 3
0
 public Task Delete(DynamicRoleData data)
 {
     return(_dbData.Remove(data));
 }
Esempio n. 4
0
 public Task Update(DynamicRoleData value)
 {
     Context.DynamicRoleData.Update(value);
     return(Context.SaveChangesAsync());
 }
Esempio n. 5
0
 public Task Add(DynamicRoleData value)
 {
     Context.DynamicRoleData.Add(value);
     return(Context.SaveChangesAsync());
 }