mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 11:53:12 +00:00
Handle string-to-int AccountId conversion in Location DTOs
- Frontend sends accountId as empty string when not set - Change DTO AccountId to string with GetAccountId() parser - Prevents JSON deserialization error on empty/non-numeric values
This commit is contained in:
parent
5a20e55138
commit
93fa76a5aa
3 changed files with 10 additions and 4 deletions
|
|
@ -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" });
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue