/// <summary> /// Maps a <see cref='Altask.Data.Model.ScheduleLog'/> object to a <see cref='Altask.Data.Dto.ScheduleLog'/> object. /// </summary> /// <param name="includeLogs">Indicates whether to load any logs associated with the object when mapping.</param> public static Altask.Data.Dto.ScheduleLog ToDto(this Altask.Data.Model.ScheduleLog entity, bool includeLogs = false) { var dto = new Altask.Data.Dto.ScheduleLog(); dto.Id = entity.Id; dto.ScheduleId = entity.ScheduleId; dto.Type = entity.Type; dto.Description = entity.Description; dto.SnapShot = entity.SnapShot; 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.ScheduleLog'/> object to a <see cref='Altask.Data.Model.ScheduleLog'/> object. /// </summary> public static Altask.Data.Model.ScheduleLog FromDto(this Altask.Data.Model.ScheduleLog model, Altask.Data.Dto.ScheduleLog entity) { model.ScheduleId = entity.ScheduleId; model.Type = entity.Type; model.Description = entity.Description; model.SnapShot = entity.SnapShot; model.Metadata = string.Empty; try { model.Metadata = ((XmlDocument)JsonConvert.DeserializeXmlNode(entity.Metadata.ToString(), "Properties")).OuterXml; } catch (Exception) {} return(model); }