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

            if (result == null)
            {
                result    = new ProjectMeasurement();
                result.Id = id;
                ctx.ProjectMeasurement.Add(result);
            }
            return(result);
        }
        public static MVC.ProjectMeasurement MapBusinessToMvc(BL.ProjectMeasurement source)
        {
            if (source == null)
            {
                return(null);
            }
            MVC.ProjectMeasurement target = new MVC.ProjectMeasurement();
            target.ProjectMeasurementId      = source.Id;
            target.ProjectMeasurementVersion = source.Version;
            target.ProjectMeasurementText    = source.Text;
            target.ProjectMeasurementStatus  = source.Status;


            return(target);
        }
 public static BL.ProjectMeasurement MapMvcToBusiness(MVC.ProjectMeasurement source)
 {
     if (source == null)
     {
         return(null);
     }
     BL.ProjectMeasurement target = BL.ProjectMeasurement.GetOrCreate(MapSupport.ActiveCtx, source.ProjectMeasurementId);
     if (target.Version != Guid.Empty && target.Version != source.ProjectMeasurementVersion)
     {
         throw new DataException("Concurrency check failed");
     }
     if (source.ProjectMeasurementIsDeleted)
     {
         target.Delete(MapSupport.ActiveCtx);
         return(null);
     }
     else
     {
         target.Version = source.ProjectMeasurementVersion;
         target.Text    = source.ProjectMeasurementText;
         target.Status  = source.ProjectMeasurementStatus;
     }
     return(target);
 }