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; } }
public Guid AddResource(DT.Resource dto) { using (var db = CreateContext()) { var entity = Convert.ToEntity(dto); db.Resources.InsertOnSubmit(entity); db.SubmitChanges(); return(entity.ResourceId); } }
public static Resource ToEntity(DT.Resource source) { if (source == null) { return(null); } var entity = new Resource(); ToEntity(source, entity); return(entity); }
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(); } }