public JuridicPersonDTO(string businessName, JuridicPersonTypeDTO type, DocumentTypeDTO documentType, long document, int companyId, LocationDTO location, ConditionRegardingVatDTO conditionRegardingVat, string phone, int zipCode, AccountDTO account, string address) { this.Id = null; this.BusinessName = businessName; this.Type = type; this.DocumentType = (DocumentTypeDTO)documentType; this.Document = document; this.CompanyId = companyId; this.Location = (LocationDTO)location; this.ConditionRegardingVat = (ConditionRegardingVatDTO)conditionRegardingVat; this.Phone = phone; this.ZipCode = zipCode; this.Account = account; this.Address = address; }
public List<LocationDTO> getLocations() { StringBuilder query = new StringBuilder(); query.AppendLine("SELECT L.Id, CONCAT(P.Name, ', ', S.Name, ', ', L.Name) Location FROM Locations L"); query.AppendLine("INNER JOIN Sections S ON L.SectionId = S.Id"); query.AppendLine("INNER JOIN Provinces P ON S.ProvinceId = P.Id;"); SqlCommand command = new SqlCommand(query.ToString(), this.conection); command.CommandType = System.Data.CommandType.Text; List<LocationDTO> locations = new List<LocationDTO>(); try { this.conection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.HasRows) { while (reader.Read()) { LocationDTO location = new LocationDTO( (int)reader["Id"], reader["Location"].ToString()); locations.Add(location); } } } } finally { if (this.conection.State == ConnectionState.Open) this.conection.Close(); } return locations; }