/// <summary> /// Creates a model based on the given domain entity. /// </summary> /// <param name="entity">The domain entity.</param> /// <param name="serializer">The JSON serializer.</param> /// <returns>The domain entity as a model.</returns> public static new ProcessResultModel Create(ResultEntity entity, IDefaultJsonSerializer serializer) { if (entity == null) { return(null); } var model = new ProcessResultModel { Id = entity.Id.ToString(), CreatedDate = entity.CreatedDate, ModifiedDate = entity.ModifiedDate, Version = entity.Version, JsonFilename = entity.JsonFilename }; var deserialized = serializer.Deserialize <ProcessResultModel>(entity.ResultSerialized); if (deserialized != null) { model.Version = deserialized.Version; model.JsonFilename = deserialized.JsonFilename; model.LabelCount = deserialized.LabelCount; model.Size = deserialized.Size; model.Images = deserialized.Images; model.Gifs = deserialized.Gifs; model.CombinedGif = deserialized.CombinedGif; } return(model); }
/// <summary> /// Creates a model based on the given domain entity. /// </summary> /// <param name="entity">The domain entity.</param> /// <param name="serializer">The JSON serializer.</param> /// <returns>The domain entity as a model.</returns> public static ResultModel Create(ResultEntity entity, IDefaultJsonSerializer serializer) { if (entity == null) { return(null); } if (Enum.TryParse(entity.ResultType.ToString(), out ResultType resultType)) { switch (resultType) { case ResultType.ProcessResult: return(ProcessResultModel.Create(entity, serializer)); default: break; } } return(null); }