public ProjectListItem(IMappingProject project, bool includeDetails = false) { Id = project.Id; Name = project.Name; OfficeName = project.Office.Name; Year = project.Year; // municipalities List <string> municipalityNames = new List <string>(); project.Municipalities.ForEach(m => municipalityNames.Add(m.Name)); if (municipalityNames.Count > 3) { MunicipalityToolTip = string.Join(", \n", municipalityNames); MunicipalityNames = string.Join(", <br>", municipalityNames.GetRange(0, 3)); MunicipalityNames += " ..."; } else { MunicipalityToolTip = ""; MunicipalityNames = string.Join(", <br>", municipalityNames); } // delivery types List <string> deliveryTypes = new List <string>(); Deliveries = new List <IMappingProjectDelivery>(); foreach (IMappingProjectDelivery delivery in project.Deliveries) { if (includeDetails) { Deliveries.Add(delivery); } string typeName = GetDeliveryTypeName(delivery.Type); if (!deliveryTypes.Contains(typeName)) { deliveryTypes.Add(typeName); } } deliveryTypes.Sort(); DeliveryTypes = string.Join(", ", deliveryTypes); // state State = GetStateName(project.State); StateToolTip = GetStateToolTip(project.State); }
public MappingProjectDetailsViewModel(IMappingProject project) { Project = new ProjectListItem(project, true); }