diff --git a/Api.SeaHavenIndustries/Controllers/LocationController.cs b/Api.SeaHavenIndustries/Controllers/LocationController.cs index 202a956..9dbb485 100644 --- a/Api.SeaHavenIndustries/Controllers/LocationController.cs +++ b/Api.SeaHavenIndustries/Controllers/LocationController.cs @@ -114,7 +114,7 @@ namespace Api.SeaHavenIndustries.Controllers Contact = model.Contact, ContactEmail = model.ContactEmail, Status = model.Status, - AccountId = model.AccountId + AccountId = model.GetAccountId() }; _db.Locations.Add(location); @@ -146,7 +146,7 @@ namespace Api.SeaHavenIndustries.Controllers exist.Contact = model.Contact; exist.ContactEmail = model.ContactEmail; exist.Status = model.Status; - exist.AccountId = model.AccountId; + exist.AccountId = model.GetAccountId(); await _db.SaveChangesAsync(); return Ok(new DataResponse { Message = "Location Updated Successfully", Status = "200" }); diff --git a/Api.SeaHavenIndustries/DTOs/EditLocation_DTO.cs b/Api.SeaHavenIndustries/DTOs/EditLocation_DTO.cs index ad26a9e..fc17b09 100644 --- a/Api.SeaHavenIndustries/DTOs/EditLocation_DTO.cs +++ b/Api.SeaHavenIndustries/DTOs/EditLocation_DTO.cs @@ -13,6 +13,9 @@ namespace Api.SeaHavenIndustries.DTOs public string? Contact { get; set; } public string? ContactEmail { get; set; } public string? Status { get; set; } - public int? AccountId { get; set; } + public string? AccountId { get; set; } + + public int? GetAccountId() => + int.TryParse(AccountId, out var id) ? id : null; } } diff --git a/Api.SeaHavenIndustries/DTOs/Location_DTO.cs b/Api.SeaHavenIndustries/DTOs/Location_DTO.cs index 079687c..e023062 100644 --- a/Api.SeaHavenIndustries/DTOs/Location_DTO.cs +++ b/Api.SeaHavenIndustries/DTOs/Location_DTO.cs @@ -12,6 +12,9 @@ namespace Api.SeaHavenIndustries.DTOs public string? Contact { get; set; } public string? ContactEmail { get; set; } public string? Status { get; set; } - public int? AccountId { get; set; } + public string? AccountId { get; set; } + + public int? GetAccountId() => + int.TryParse(AccountId, out var id) ? id : null; } }