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

            if (result == null)
            {
                result    = new ProjectAction();
                result.Id = id;
                ctx.ProjectAction.Add(result);
            }
            return(result);
        }
        public static MVC.ProjectAction MapBusinessToMvc(BL.ProjectAction source)
        {
            if (source == null)
            {
                return(null);
            }
            MVC.ProjectAction target = new MVC.ProjectAction();
            target.ProjectActionId      = source.Id;
            target.ProjectActionVersion = source.Version;
            target.ProjectActionText    = source.Text;
            target.ProjectActionStatus  = source.Status;


            return(target);
        }
 public static BL.ProjectAction MapMvcToBusiness(MVC.ProjectAction source)
 {
     if (source == null)
     {
         return(null);
     }
     BL.ProjectAction target = BL.ProjectAction.GetOrCreate(MapSupport.ActiveCtx, source.ProjectActionId);
     if (target.Version != Guid.Empty && target.Version != source.ProjectActionVersion)
     {
         throw new DataException("Concurrency check failed");
     }
     if (source.ProjectActionIsDeleted)
     {
         target.Delete(MapSupport.ActiveCtx);
         return(null);
     }
     else
     {
         target.Version = source.ProjectActionVersion;
         target.Text    = source.ProjectActionText;
         target.Status  = source.ProjectActionStatus;
     }
     return(target);
 }