public void Init(string title, string docId) { Title = title ?? "Detaljer"; Availability = new DocumentAvailabilityDto {AvailableCount = 1}; Availabilities = new DocumentAvailabilityViewModel[0]; Load(docId); }
private static IEnumerable<DocumentAvailabilityDto> MapAvailability(Document document) { if (null == document.AvailabilityInfo) yield break; foreach (var availability in document.AvailabilityInfo) { if (null == availability) continue; var dto = new DocumentAvailabilityDto { Branch = availability.Branch, AvailableCount = availability.AvailableCount, TotalCount = availability.TotalCount, Department = availability.Department.DefaultIfEmpty("").Aggregate((acc, dep) => { if (String.IsNullOrEmpty(acc)) return dep; return acc + ", " + dep; }), Collection = availability.PlacementCode, Location = document.LocationCode }; DateTime date; if (DateTime.TryParse(availability.EarliestAvailableDateFormatted, out date)) { dto.EstimatedAvailableDate = date; } yield return dto; } }