/// <summary> /// Create a new instance of a Parcel. /// </summary> /// <param name="pid"></param> /// <param name="lat"></param> /// <param name="lng"></param> /// <param name="agency"></param> /// <returns></returns> public static Entity.Parcel CreateParcel(int pid, double lat, double lng, Entity.Agency agency, Entity.Address address = null) { agency ??= EntityHelper.CreateAgency(pid); if (address == null) { address = EntityHelper.CreateAddress(pid, "1234 Street", null, "V9C9C9"); } var classification = EntityHelper.CreatePropertyClassification("classification"); return(new Entity.Parcel(pid, lat, lng) { Id = pid, Agency = agency, AgencyId = agency.Id, Address = address, AddressId = address.Id, Classification = classification, ClassificationId = classification.Id, Description = $"description-{pid}", CreatedById = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, UpdatedById = Guid.NewGuid(), UpdatedOn = DateTime.UtcNow, RowVersion = new byte[] { 12, 13, 14 } }); }
/// <summary> /// Create a new instance of a Project. /// </summary> /// <param name="id"></param> /// <param name="agency"></param> /// <param name="tierLevel"></param> /// <param name="workflowStatus"></param> /// <returns></returns> public static Entity.Project CreateProject(int id, Entity.Agency agency = null, Entity.TierLevel tierLevel = null, Entity.WorkflowProjectStatus workflowStatus = null, Entity.ProjectRisk risk = null) { agency ??= EntityHelper.CreateAgency(id); tierLevel ??= EntityHelper.CreateTierLevel(id, "tierLevel"); risk ??= EntityHelper.CreateProjectRisk(id, "risk", "risk", 1); var status = workflowStatus?.Status ?? EntityHelper.CreateProjectStatus("Draft", "DR"); var workflow = workflowStatus?.Workflow ?? EntityHelper.CreateWorkflow(id, "Submit", "SUBMIT-DISPOSAL", new[] { status }); var user = CreateUser(Guid.NewGuid(), "project tester", "asasa", "asasa", null, agency); return(new Entity.Project($"SPP-{id:00000}", $"test-{id}", tierLevel) { ReportedFiscalYear = DateTime.UtcNow.GetFiscalYear(), ActualFiscalYear = DateTime.UtcNow.GetFiscalYear(), Risk = risk, RiskId = risk.Id, Agency = agency, AgencyId = agency.Id, Workflow = workflow, WorkflowId = workflow?.Id, Status = status, StatusId = status.Id, Description = $"description-{id}", CreatedBy = user, CreatedById = user.Id, CreatedOn = DateTime.UtcNow, UpdatedById = user.Id, UpdatedBy = user, PublicNote = $"publicNote-{id}", PrivateNote = $"privateNote-{id}", UpdatedOn = DateTime.UtcNow, Metadata = "{offerAmount: 123}", RowVersion = new byte[] { 12, 13, 14 } }); }
/// <summary> /// Create a new instance of a Parcel. /// </summary> /// <param name="context"></param> /// <param name="pid"></param> /// <param name="lat"></param> /// <param name="lng"></param> /// <param name="agency"></param> /// <returns></returns> public static Entity.Parcel CreateParcel(this PimsContext context, int pid, double lat = 0, double lng = 0, Entity.Agency agency = null) { agency ??= context.Agencies.FirstOrDefault() ?? EntityHelper.CreateAgency(pid); var address = context.CreateAddress(pid, "1234 Street", null, "V9C9C9"); var classification = context.PropertyClassifications.FirstOrDefault(s => s.Id == 1) ?? EntityHelper.CreatePropertyClassification("classification"); var parcel = new Entity.Parcel(pid, lat, lng) { Id = pid, Agency = agency, AgencyId = agency.Id, Address = address, AddressId = address.Id, Classification = classification, ClassificationId = classification.Id, Description = $"description-{pid}", CreatedById = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, UpdatedById = Guid.NewGuid(), UpdatedOn = DateTime.UtcNow, RowVersion = new byte[] { 12, 13, 14 } }; context.Parcels.Add(parcel); return(parcel); }
/// <summary> /// Create a new List with new instances of Parcels. /// </summary> /// <param name="context"></param> /// <param name="startId"></param> /// <param name="count"></param> /// <returns></returns> public static List <Entity.Parcel> CreateParcels(this PimsContext context, int startId, int count) { var agency = context.Agencies.FirstOrDefault(a => a.Id == 1) ?? EntityHelper.CreateAgency(startId); var parcels = new List <Entity.Parcel>(count); for (var i = startId; i < (startId + count); i++) { parcels.Add(context.CreateParcel(i, 0, 0, agency)); } return(parcels); }
/// <summary> /// Create a new instance of an AccessRequest for a default user. /// </summary> /// <param name="id"></param> /// <param name="username"></param> /// <param name="firstName"></param> /// <param name="lastName"></param> /// <param name="role"></param> /// <param name="agency"></param> /// <returns></returns> public static Entity.User CreateUser(Guid id, string username, string firstName = "given name", string lastName = "surname", Entity.Role role = null, Entity.Agency agency = null) { var user = new Entity.User(id, username, $"{firstName}.{lastName}@email.com") { DisplayName = $"{lastName}, {firstName}", RowVersion = new byte[] { 12, 13, 14 } }; user.Roles.Add(new Entity.UserRole(user, role ?? EntityHelper.CreateRole("Real Estate Manager"))); user.Agencies.Add(new Entity.UserAgency(user, agency ?? EntityHelper.CreateAgency())); return(user); }
/// <summary> /// Create a new instance of a Project. /// </summary> /// <param name="context"></param> /// <param name="id"></param> /// <param name="agency"></param> /// <param name="workflowStatus"></param> /// <param name="risk"></param> /// <returns></returns> public static Entity.Project CreateProject(this PimsContext context, int id, Entity.Agency agency = null, Entity.WorkflowProjectStatus workflowStatus = null, Entity.ProjectRisk risk = null) { agency ??= context.Agencies.OrderBy(a => a.Id).FirstOrDefault() ?? EntityHelper.CreateAgency(1); risk ??= context.ProjectRisks.FirstOrDefault() ?? EntityHelper.CreateProjectRisk(1, "risk", "risk", 1); workflowStatus ??= context.WorkflowProjectStatus.FirstOrDefault(ws => ws.WorkflowId == 1 && ws.StatusId == 1); if (workflowStatus == null) { var status = workflowStatus?.Status ?? EntityHelper.CreateProjectStatus("Draft", "DR"); var workflow = workflowStatus?.Workflow ?? EntityHelper.CreateWorkflow(id, "Submit", "SUBMIT-DISPOSAL", new[] { status }); workflowStatus ??= workflow.Status.First(); } var tierLevel = context.TierLevels.FirstOrDefault(s => s.Id == 1) ?? EntityHelper.CreateTierLevel("tierLevel"); var project = EntityHelper.CreateProject(id, agency, tierLevel, workflowStatus, risk); context.Projects.Add(project); return(project); }
/// <summary> /// Creates a new instance of a Building. /// </summary> /// <param name="context"></param> /// <param name="parcel"></param> /// <param name="id"></param> /// <param name="name"></param> /// <param name="lat"></param> /// <param name="lng"></param> /// <param name="agency"></param> /// <returns></returns> public static Entity.Building CreateBuilding(this PimsContext context, Entity.Parcel parcel, int id, string projectNumber = null, string name = null, int lat = 0, int lng = 0, Entity.Agency agency = null) { name ??= $"l{id}"; agency ??= parcel?.Agency ?? context.Agencies.FirstOrDefault() ?? EntityHelper.CreateAgency(id); var address = (parcel == null ? EntityHelper.CreateAddress(context, id, "1234 Street", null, "V9C9C9") : EntityHelper.CreateAddress(id, parcel.Address.Address1, parcel.Address.Address2, parcel.Address.AdministrativeArea, parcel.Address.Province, parcel.Address.Postal)); var predominateUse = context.BuildingPredominateUses.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingPredominateUse("use");; var constructionType = context.BuildingConstructionTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingConstructionType("type"); var occupantType = context.BuildingOccupantTypes.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreateBuildingOccupantType("occupant"); var classification = context.PropertyClassifications.FirstOrDefault(b => b.Id == 1) ?? EntityHelper.CreatePropertyClassification("classification"); var building = new Entity.Building(parcel, lat, lng) { Id = id, Name = name, ProjectNumbers = projectNumber, AgencyId = agency.Id, Agency = agency, AddressId = address.Id, Address = address, Classification = classification, ClassificationId = classification.Id, Description = $"description-{id}", BuildingPredominateUse = predominateUse, BuildingPredominateUseId = predominateUse.Id, BuildingConstructionType = constructionType, BuildingConstructionTypeId = constructionType.Id, BuildingOccupantType = occupantType, BuildingOccupantTypeId = occupantType.Id, CreatedById = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, UpdatedById = Guid.NewGuid(), UpdatedOn = DateTime.UtcNow, RowVersion = new byte[] { 12, 13, 14 } }; if (parcel != null) { var parcelBuilding = new Entity.ParcelBuilding(parcel, building); } context.Buildings.Add(building); return(building); }
/// <summary> /// Create a new List with new instances of Projects. /// </summary> /// <param name="context"></param> /// <param name="startId"></param> /// <param name="count"></param> /// <param name="agency"></param> /// <param name="workflowStatus"></param> /// <param name="risk"></param> /// <returns></returns> public static List <Entity.Project> CreateProjects(this PimsContext context, int startId, int count, Entity.Agency agency = null, Entity.WorkflowProjectStatus workflowStatus = null, Entity.ProjectRisk risk = null) { agency ??= context.Agencies.FirstOrDefault(a => a.Id == 1) ?? EntityHelper.CreateAgency(startId); risk ??= context.ProjectRisks.FirstOrDefault() ?? EntityHelper.CreateProjectRisk(1, "risk", "risk", 1); workflowStatus ??= context.WorkflowProjectStatus.FirstOrDefault(ws => ws.WorkflowId == 1 && ws.StatusId == 1); if (workflowStatus == null) { var status = workflowStatus?.Status ?? EntityHelper.CreateProjectStatus("Draft", "DR"); var workflow = workflowStatus?.Workflow ?? EntityHelper.CreateWorkflow(startId, "Submit", "SUBMIT-DISPOSAL", new[] { status }); workflowStatus ??= workflow.Status.First(); } var projects = new List <Entity.Project>(count); for (var i = startId; i < (startId + count); i++) { projects.Add(context.CreateProject(i, agency, workflowStatus, risk)); } return(projects); }
/// <summary> /// Creates a new instance of a Building. /// </summary> /// <param name="id"></param> /// <param name="projectNumber"></param> /// <param name="name"></param> /// <param name="lat"></param> /// <param name="lng"></param> /// <param name="agency"></param> public static Entity.Building CreateBuilding(int id, string projectNumber = null, string name = null, int lat = 0, int lng = 0, Entity.Agency agency = null) { projectNumber ??= $"p{id}"; agency ??= agency ?? EntityHelper.CreateAgency(id); var address = EntityHelper.CreateAddress(id, "1234 Street", null, "V9C9C9"); var predominateUse = EntityHelper.CreateBuildingPredominateUse("use"); var constructionType = EntityHelper.CreateBuildingConstructionType("type"); var occupantType = EntityHelper.CreateBuildingOccupantType("occupant"); var classification = EntityHelper.CreatePropertyClassification("classification"); return(new Entity.Building() { Id = id, ProjectNumbers = $"[\"{projectNumber}\"]", AgencyId = agency.Id, Agency = agency, Name = name, AddressId = address.Id, Address = address, Location = new Point(lng, lat) { SRID = 4326 }, Classification = classification, ClassificationId = classification.Id, Description = $"description-{id}", BuildingPredominateUse = predominateUse, BuildingPredominateUseId = predominateUse.Id, BuildingConstructionType = constructionType, BuildingConstructionTypeId = constructionType.Id, BuildingOccupantType = occupantType, BuildingOccupantTypeId = occupantType.Id, CreatedById = Guid.NewGuid(), CreatedOn = DateTime.UtcNow, UpdatedById = Guid.NewGuid(), UpdatedOn = DateTime.UtcNow, RowVersion = new byte[] { 12, 13, 14 }, PropertyTypeId = 1, }); }
/// <summary> /// Create a new instance of a Project. /// </summary> /// <param name="context"></param> /// <param name="id"></param> /// <param name="agency"></param> /// <returns></returns> public static Entity.Project CreateProject(this PimsContext context, int id, int agencyId) { var agency = context.Agencies.Find(agencyId) ?? EntityHelper.CreateAgency(agencyId); return(context.CreateProject(id, agency)); }
/// <summary> /// Create a new instance of a Project. /// </summary> /// <param name="id"></param> /// <param name="agencyId"></param> /// <returns></returns> public static Entity.Project CreateProject(int id, int agencyId) { var agency = EntityHelper.CreateAgency(agencyId); return(CreateProject(id, agency)); }
/// <summary> /// Create a new instance of a Parcel. /// </summary> /// <param name="pid"></param> /// <param name="lat"></param> /// <param name="lng"></param> /// <param name="agencyId"></param> /// <returns></returns> public static Entity.Parcel CreateParcel(int pid, double lat = 0, double lng = 0, int agencyId = 1) { var agency = EntityHelper.CreateAgency(agencyId); return(CreateParcel(pid, lat, lng, agency)); }
/// <summary> /// Create a new instance of a Parcel. /// </summary> /// <param name="pid"></param> /// <param name="lat"></param> /// <param name="lng"></param> /// <param name="agencyId"></param> /// <returns></returns> public static Entity.Parcel CreateParcel(int pid, double lat = 0, double lng = 0, int agencyId = 1, Entity.Address address = null) { var agency = EntityHelper.CreateAgency(agencyId); return(CreateParcel(pid, lat, lng, agency, address)); }