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

            if (result == null)
            {
                result    = new ProjectResult();
                result.Id = id;
                ctx.ProjectResult.Add(result);
            }
            return(result);
        }
        public static MVC.ProjectResult MapBusinessToMvc(BL.ProjectResult source)
        {
            if (source == null)
            {
                return(null);
            }
            MVC.ProjectResult target = new MVC.ProjectResult();
            target.ProjectResultId      = source.Id;
            target.ProjectResultVersion = source.Version;
            target.ProjectResultText    = source.Text;


            return(target);
        }
 public static BL.ProjectResult MapMvcToBusiness(MVC.ProjectResult source)
 {
     if (source == null)
     {
         return(null);
     }
     BL.ProjectResult target = BL.ProjectResult.GetOrCreate(MapSupport.ActiveCtx, source.ProjectResultId);
     if (target.Version != Guid.Empty && target.Version != source.ProjectResultVersion)
     {
         throw new DataException("Concurrency check failed");
     }
     if (source.ProjectResultIsDeleted)
     {
         target.Delete(MapSupport.ActiveCtx);
         return(null);
     }
     else
     {
         target.Version = source.ProjectResultVersion;
         target.Text    = source.ProjectResultText;
     }
     return(target);
 }