예제 #1
0
 public static void ToEntity(DT.Resource source, Resource target)
 {
     if ((source != null) && (target != null))
     {
         target.ResourceId = source.Id; target.Name = source.Name; target.ParentResourceId = source.ParentResourceId;
     }
 }
예제 #2
0
 public Guid AddResource(DT.Resource dto)
 {
     using (var db = CreateContext()) {
         var entity = Convert.ToEntity(dto);
         db.Resources.InsertOnSubmit(entity);
         db.SubmitChanges();
         return(entity.ResourceId);
     }
 }
예제 #3
0
        public static Resource ToEntity(DT.Resource source)
        {
            if (source == null)
            {
                return(null);
            }
            var entity = new Resource(); ToEntity(source, entity);

            return(entity);
        }
예제 #4
0
 public void UpdateResource(DT.Resource dto)
 {
     using (var db = CreateContext()) {
         var entity = db.Resources.FirstOrDefault(x => x.ResourceId == dto.Id);
         if (entity == null)
         {
             db.Resources.InsertOnSubmit(Convert.ToEntity(dto));
         }
         else
         {
             Convert.ToEntity(dto, entity);
         }
         db.SubmitChanges();
     }
 }