/// <summary> /// Maps all the non-primary key and tracking properties of a <see cref='Altask.Data.Dto.AssetLog'/> object to a <see cref='Altask.Data.Model.AssetLog'/> object. /// </summary> public static Altask.Data.Model.AssetLog FromDto(this Altask.Data.Model.AssetLog model, Altask.Data.Dto.AssetLog entity) { model.AssetId = entity.AssetId; model.AssetLogTypeId = entity.AssetLogTypeId; model.Comment = entity.Comment; model.Description = entity.Description; model.Metadata = string.Empty; try { model.Metadata = ((XmlDocument)JsonConvert.DeserializeXmlNode(entity.Metadata.ToString(), "Properties")).OuterXml; } catch (Exception) {} return(model); }
/// <summary> /// Maps a <see cref='Altask.Data.Model.AssetLog'/> object to a <see cref='Altask.Data.Dto.AssetLog'/> object. /// </summary> public static Altask.Data.Dto.AssetLog ToDto(this Altask.Data.Model.AssetLog entity) { var dto = new Altask.Data.Dto.AssetLog(); dto.Id = entity.Id; dto.AssetId = entity.AssetId; dto.AssetLogTypeId = entity.AssetLogTypeId; dto.Comment = entity.Comment; dto.Description = entity.Description; 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; if (entity.Type != null) { dto.Type = entity.Type.ToDto(); } dto.Resolutions = new List <Altask.Data.Dto.AssetLogResolution>(); if (entity.Resolutions != null) { foreach (var item in entity.Resolutions) { dto.Resolutions.Add(item.ToDto()); } } return(dto); }