dragzun
✅ Pass status as parameter in controller
ok, i got a bit confused, i am passing my new enum as a parameter but i don't know how can i compare the enums between each other ( the existing one and the one i added) https://paste.mod.gg/nxcfbjkygebz/0
74 replies
✅ Pass status as parameter in controller
thank you, i will give it a shot tomorrow. one more off topic question : if i have a dto with 5 properties, which is being used to by entity A , but I have another entity B that shares 3 of those properties, is there a way to use the same dto? Or just create a separate one with those 3 properties
74 replies
✅ Pass status as parameter in controller
sorry to bother you again, actually I am happy I didnt close this yet. So basically the above method doesn't work as intended, since if a client is already inactive and i'm going to make a call to inactive it, it will actually activate the client. I was thinking I could add an enum status parameter to it, but I don't know how would I update the entity with that status ?
74 replies
✅ Pass status as parameter in controller
public async Task<int> UpdateClientStatusAsync(int clientId)
{
var client = _context.Clients.First(w => w.ClientId == clientId);
if ( client.SysClientStatusId == (int)SysClientStatusType.Active) { client.SysClientStatusId = (int)SysClientStatusType.Inactive; } else if (client.SysClientStatusId == (int)SysClientStatusType.Inactive) { client.SysClientStatusId = (int)SysClientStatusType.Active; } await _context.SaveChangesAsync(); return client.ClientId; }
if ( client.SysClientStatusId == (int)SysClientStatusType.Active) { client.SysClientStatusId = (int)SysClientStatusType.Inactive; } else if (client.SysClientStatusId == (int)SysClientStatusType.Inactive) { client.SysClientStatusId = (int)SysClientStatusType.Active; } await _context.SaveChangesAsync(); return client.ClientId; }
74 replies