fix(vendors): keep location fallback atomic

This commit is contained in:
Alexandre Brandizzi 2026-08-21 09:40:51 -03:00
parent d0a90483b3
commit 9c3da9b5e3
2 changed files with 17 additions and 8 deletions

View file

@ -440,15 +440,15 @@ public class VendorDataServiceTests
Name = "Searchable Co",
NormalizedName = "searchable co",
City = "Chicago",
State = "IL"
State = null
};
context.VendorCompanies.Add(company);
context.Vendors.Add(new Vendor
{
CompanyName = "Searchable Co",
ContactName = "Pat",
City = null,
State = null,
City = "Stale City",
State = "TX",
IsActive = true,
IsDeleted = false,
Company = company
@ -461,10 +461,15 @@ public class VendorDataServiceTests
1,
50,
isActive: true,
locations: new[] { "Chicago, IL" });
locations: new[] { "Chicago" });
search.Items.Should().ContainSingle(i => i.ContactName == "Pat");
location.Items.Should().ContainSingle(i => i.ContactName == "Pat");
var searchRow = search.Items.Should().ContainSingle(i => i.ContactName == "Pat").Subject;
searchRow.City.Should().Be("Chicago");
searchRow.State.Should().BeNull();
var locationRow = location.Items.Should().ContainSingle(i => i.ContactName == "Pat").Subject;
locationRow.City.Should().Be("Chicago");
locationRow.State.Should().BeNull();
}
[Theory]

View file

@ -200,10 +200,14 @@ namespace SeaHaven.DataServices.Implementation
CompanyPhone = v.CompanyPhone,
PreferredContact = v.PreferredContact,
Address = v.Address,
City = v.Company != null && v.Company.City != null && v.Company.City.Trim() != ""
City = v.Company != null &&
((v.Company.City != null && v.Company.City.Trim() != "") ||
(v.Company.State != null && v.Company.State.Trim() != ""))
? v.Company.City
: v.City,
State = v.Company != null && v.Company.State != null && v.Company.State.Trim() != ""
State = v.Company != null &&
((v.Company.City != null && v.Company.City.Trim() != "") ||
(v.Company.State != null && v.Company.State.Trim() != ""))
? v.Company.State
: v.State,
Zip = v.Zip,