Exemplo n.º 1
0
 public static DA.ClientGroup ToEntity(DT.ClientGroup source)
 {
     return(new DA.ClientGroup()
     {
         Id = source.Id,
         Description = source.Description,
         Name = source.Name,
     });
 }
Exemplo n.º 2
0
 public void RemoveResourceFromGroup(DT.Resource resource, DT.ClientGroup group)
 {
     using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) {
         var query = context.ResourceResourceGroups.Where(x => x.ResourceId == resource.Id && x.ResourceGroupId == group.Id);
         if (query.Count() > 0)
         {
             context.ResourceResourceGroups.DeleteOnSubmit(query.First());
             context.SubmitChanges();
         }
     }
 }
Exemplo n.º 3
0
        public void AddResourceToGroup(DT.Resource resource, DT.ClientGroup group)
        {
            using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) {
                DA.ResourceResourceGroup rrg = new DA.ResourceResourceGroup()
                {
                    ResourceId      = resource.Id,
                    ResourceGroupId = group.Id
                };

                context.ResourceResourceGroups.InsertOnSubmit(rrg);
                context.SubmitChanges();
            }
        }
Exemplo n.º 4
0
        public Guid AddClientGroup(DT.ClientGroup group)
        {
            using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) {
                if (group.Id == Guid.Empty)
                {
                    group.Id = Guid.NewGuid();
                }

                var entity = Convert.ToEntity(group);
                context.Resources.InsertOnSubmit(entity);
                context.SubmitChanges();
                return(entity.Id);
            }
        }
Exemplo n.º 5
0
        public void DeleteClientGroup(DT.ClientGroup clientGroup)
        {
            RoleVerifier.AuthenticateForAllRoles(AccessServiceRoles.Administrator);

            using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) {
                //load clientGroup because we could get a detached object
                var query = from c in context.GetTable <DA.Resource>().OfType <DA.ClientGroup>()
                            where c.Id == clientGroup.Id
                            select c;
                if (query.Count() > 0)
                {
                    context.Resources.DeleteOnSubmit(query.First());
                    context.SubmitChanges();
                }
            }
        }
Exemplo n.º 6
0
        public void UpdateClientGroup(DT.ClientGroup clientGroup)
        {
            using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) {
                var query = from g in context.Resources.OfType <DA.ClientGroup>()
                            where g.Id == clientGroup.Id
                            select g;

                if (query.Count() > 0)
                {
                    var entity = query.First();
                    entity.Name        = clientGroup.Name;
                    entity.Description = clientGroup.Description;
                    context.SubmitChanges();
                }
            }
        }