public static InterestGroup GetOrCreate(ProjectReportDemoCtx ctx, Guid id)
        {
            InterestGroup result = ctx.InterestGroup.SingleOrDefault(item => item.Id == id);

            if (result == null)
            {
                result    = new InterestGroup();
                result.Id = id;
                ctx.InterestGroup.Add(result);
            }
            return(result);
        }
        public static MVC.InterestGroup MapBusinessToMvc(BL.InterestGroup source)
        {
            if (source == null)
            {
                return(null);
            }
            MVC.InterestGroup target = new MVC.InterestGroup();
            target.InterestGroupId      = source.Id;
            target.InterestGroupVersion = source.Version;
            target.InterestGroupName    = source.Name;


            return(target);
        }
 public static BL.InterestGroup MapMvcToBusiness(MVC.InterestGroup source)
 {
     if (source == null)
     {
         return(null);
     }
     BL.InterestGroup target = BL.InterestGroup.GetOrCreate(MapSupport.ActiveCtx, source.InterestGroupId);
     if (target.Version != Guid.Empty && target.Version != source.InterestGroupVersion)
     {
         throw new DataException("Concurrency check failed");
     }
     if (source.InterestGroupIsDeleted)
     {
         target.Delete(MapSupport.ActiveCtx);
         return(null);
     }
     else
     {
         target.Version = source.InterestGroupVersion;
         target.Name    = source.InterestGroupName;
     }
     return(target);
 }