Beispiel #1
0
 public static void ToEntity(DT.SlaveGroup source, SlaveGroup target)
 {
     if ((source != null) && (target != null))
     {
         target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
     }
 }
Beispiel #2
0
        public static SlaveGroup ToEntity(DT.SlaveGroup source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new SlaveGroup(); ToEntity(source, entity);

            return(entity);
        }
Beispiel #3
0
 public Guid AddSlaveGroup(DT.SlaveGroup dto)
 {
     using (var db = CreateContext()) {
         if (dto.Id == Guid.Empty)
         {
             dto.Id = Guid.NewGuid();
         }
         var entity = Convert.ToEntity(dto);
         db.Resources.InsertOnSubmit(entity);
         db.SubmitChanges();
         return(entity.ResourceId);
     }
 }
Beispiel #4
0
 public void UpdateSlaveGroup(DT.SlaveGroup dto)
 {
     using (var db = CreateContext()) {
         var entity = db.Resources.OfType <SlaveGroup>().FirstOrDefault(x => x.ResourceId == dto.Id);
         if (entity == null)
         {
             db.Resources.InsertOnSubmit(Convert.ToEntity(dto));
         }
         else
         {
             Convert.ToEntity(dto, entity);
         }
         db.SubmitChanges();
     }
 }