/// <summary> /// Update the originalProperty.agencyId and originalProperty.classificationId using the specified property. /// </summary> /// <param name="originalProperty"></param> /// <param name="property"></param> /// <returns></returns> public static Entity.Property UpdateProjectProperty(this Entity.ProjectProperty originalProperty, Entity.ProjectProperty property) { switch (property.PropertyType) { case (Entity.PropertyTypes.Land): if (originalProperty.Parcel == null || property.Parcel == null) { throw new InvalidOperationException("Unable to transfer parcel."); } originalProperty.Parcel.AgencyId = property.Parcel.AgencyId; originalProperty.Parcel.ClassificationId = property.Parcel.ClassificationId; originalProperty.Parcel.ProjectNumber = null; return(originalProperty.Parcel); case (Entity.PropertyTypes.Building): if (originalProperty.Building == null || property.Building == null) { throw new InvalidOperationException("Unable to transfer building."); } originalProperty.Building.AgencyId = property.Building.AgencyId; originalProperty.Building.ClassificationId = property.Building.ClassificationId; originalProperty.Building.ProjectNumber = null; return(originalProperty.Building); } return(null); }
/// <summary> /// Update the property.ProjectNumbers with the specified 'projectNumber', de-duplicating based on the numeric portion. /// </summary> /// <param name="property"></param> /// <param name="projectNumber"></param> /// <returns></returns> public static Entity.Property UpdateProjectNumbers(this Entity.ProjectProperty property, string projectNumber) { IEnumerable <string> projectNumbers; switch (property.PropertyType) { case (Entity.PropertyTypes.Land): if (property.Parcel == null) { throw new InvalidOperationException("Unable to update parcel project number."); } projectNumbers = JsonSerializer.Deserialize <IEnumerable <string> >(property.Parcel.ProjectNumbers ?? "[]"); property.Parcel.ProjectNumbers = JsonSerializer.Serialize(AddProjectNumber(projectNumbers, projectNumber)); return(property.Parcel); case (Entity.PropertyTypes.Building): if (property.Building == null) { throw new InvalidOperationException("Unable to update building project number."); } projectNumbers = JsonSerializer.Deserialize <IEnumerable <string> >(property.Building.ProjectNumbers ?? "[]"); property.Building.ProjectNumbers = JsonSerializer.Serialize(AddProjectNumber(projectNumbers, projectNumber)); return(property.Building); } return(null); }
/// <summary> /// Update the originalProperty.agencyId and originalProperty.classificationId using the specified property. /// </summary> /// <param name="originalProperty"></param> /// <param name="property"></param> /// <returns></returns> public static Entity.Property UpdateProjectProperty(this Entity.ProjectProperty originalProperty, Entity.ProjectProperty property) { switch (property.PropertyType) { case (Entity.PropertyTypes.Land): if (originalProperty.Parcel == null || property.Parcel == null) { throw new InvalidOperationException("Unable to transfer parcel."); } originalProperty.Parcel.AgencyId = property.Parcel.AgencyId; originalProperty.Parcel.ClassificationId = property.Parcel.ClassificationId; originalProperty.Parcel.ProjectNumbers = "[]"; originalProperty.Parcel.PropertyTypeId = (int)PropertyTypes.Land; // when an agency transition occurs, and subdivisions should transition into parcels. return(originalProperty.Parcel); case (Entity.PropertyTypes.Building): if (originalProperty.Building == null || property.Building == null) { throw new InvalidOperationException("Unable to transfer building."); } originalProperty.Building.AgencyId = property.Building.AgencyId; originalProperty.Building.ClassificationId = property.Building.ClassificationId; originalProperty.Building.ProjectNumbers = "[]"; return(originalProperty.Building); } return(null); }
/// <summary> /// Add a building(s) to the project. /// </summary> /// <param name="project"></param> /// <param name="buildings"></param> /// <returns></returns> public static IEnumerable <Entity.ProjectProperty> AddProperty(this Entity.Project project, params Entity.Building[] buildings) { var result = new List <Entity.ProjectProperty>(); foreach (var b in buildings) { var pp = new Entity.ProjectProperty(project, b); project.Properties.Add(pp); result.Add(pp); } return(result); }
/// <summary> /// Add a parcel(s) to the project. /// </summary> /// <param name="project"></param> /// <param name="parcels"></param> /// <returns></returns> public static IEnumerable <Entity.ProjectProperty> AddProperty(this Entity.Project project, params Entity.Parcel[] parcels) { var result = new List <Entity.ProjectProperty>(); foreach (var p in parcels) { var pp = new Entity.ProjectProperty(project, p); project.Properties.Add(pp); result.Add(pp); } return(result); }
/// <summary> /// Update the property.ProjectNumber with the specified 'projectNumber'. /// </summary> /// <param name="property"></param> /// <param name="projectNumber"></param> /// <returns></returns> public static Entity.Property UpdateProjectNumber(this Entity.ProjectProperty property, string projectNumber) { switch (property.PropertyType) { case (Entity.PropertyTypes.Land): if (property.Parcel == null) { throw new InvalidOperationException("Unable to update parcel project number."); } property.Parcel.ProjectNumber = projectNumber; return(property.Parcel); case (Entity.PropertyTypes.Building): if (property.Building == null) { throw new InvalidOperationException("Unable to update building project number."); } property.Building.ProjectNumber = projectNumber; return(property.Building); } return(null); }