/// <summary> /// Maps a <see cref='Altask.Data.Model.OccurrenceLog'/> object to a <see cref='Altask.Data.Dto.OccurrenceLog'/> object. /// </summary> /// <param name="includeLogs">Indicates whether to load any logs associated with the object when mapping.</param> public static Altask.Data.Dto.OccurrenceLog ToDto(this Altask.Data.Model.OccurrenceLog entity, bool includeLogs = false) { var dto = new Altask.Data.Dto.OccurrenceLog(); dto.Id = entity.Id; dto.OccurrenceId = entity.OccurrenceId; dto.Type = entity.Type; dto.Description = entity.Description; dto.JsonModel = entity.JsonModel; dto.Metadata = JsonConvert.DeserializeObject("{Properties: []}"); if (!string.IsNullOrEmpty(entity.Metadata)) { try { XmlDocument doc = new XmlDocument(); doc.LoadXml(entity.Metadata); string json = Json.SerizlieXmlDocument(doc); dto.Metadata = JsonConvert.DeserializeObject(json); } catch (Exception) {} } dto.CreatedBy = entity.CreatedBy; dto.CreatedOn = entity.CreatedOn; dto.UpdatedBy = entity.UpdatedBy; dto.UpdatedOn = entity.UpdatedOn; return(dto); }
/// <summary> /// Maps all the non-primary key and tracking properties of a <see cref='Altask.Data.Dto.OccurrenceLog'/> object to a <see cref='Altask.Data.Model.OccurrenceLog'/> object. /// </summary> public static Altask.Data.Model.OccurrenceLog FromDto(this Altask.Data.Model.OccurrenceLog model, Altask.Data.Dto.OccurrenceLog entity) { model.OccurrenceId = entity.OccurrenceId; model.Type = entity.Type; model.Description = entity.Description; model.JsonModel = entity.JsonModel; model.Metadata = string.Empty; try { model.Metadata = ((XmlDocument)JsonConvert.DeserializeXmlNode(entity.Metadata.ToString(), "Properties")).OuterXml; } catch (Exception) {} return(model); }