dragzun
dragzun
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
Thanks a lot for all your help!
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
thanks a lot, _ represents the entity, right ?
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ 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
CC#
Created by dragzun on 5/16/2023 in #help
✅ 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
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
I assume it has to be a different enum than the one that it is currently using?
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
yes, i know. Now I am considering either passing another parameter as an enum, or just create a dto with the client id and status id and have it as parameter. What would be your suggestion
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ 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
CC#
Created by dragzun on 5/19/2023 in #help
✅ LINQ Include does not bring all related entities
ok, i needed ThenInclude
2 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
got it, thanks a lot again 🙂
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
ah nvm, you were talking about the format 🙂
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
so you re saying its fine as it is ?
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
public enum SysClientStatusType { Inactive = 435, Active = 788,
}
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
casue the status is an int in db
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
sorry
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
but it looks kinda bad in my opinion
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
I am using an enum for it
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ 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; }
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
basically I have a method which changes status of a client, again , from Active to Inactive, based on the clientId : this is how it looks
74 replies
CC#
Created by dragzun on 5/16/2023 in #help
✅ Pass status as parameter in controller
Thank you for all your help. Can I ask you one more thing ? its more of a refactoring suggestion of a method that works but I really don't like how it looks
74 replies