softmek
β (MVC web app) How can I handle exceptions/errors in this case?
You can use https://codeseven.github.io/toastr/demo.html
24 replies
β (MVC web app) How can I handle exceptions/errors in this case?
π― . I have over 7 year experience and that's the best way you will ever handle that, but avoid absolute url inside your application https://www.linkedin.com/in/haron-njuguna/
24 replies
β
How to deserialize JSON in .NET when my base class is generic?
You're reconfiguring the code to handle complex JSON structures by evaluating JsonElements and introducing a more intricate class hierarchy. Using an enum to discern abstract base classes and their derived types allows for a more nuanced representation of various event information types. This adjustment accommodates additional fields in the derived types while addressing the lack of parameterless constructors, likely impacting JSON serialization/deserialization processes. Even though the system wasn't initially designed for JSON compatibility, this restructuring aligns well with the project's requirements for a demo application, providing a more tailored approach to handle diverse data structures.
14 replies
β
How to deserialize JSON in .NET when my base class is generic?
When attempting to directly deserialize a derived generic class like ClientEventInfo using System.Text.Json.JsonSerializer, a TypeInitializationException might arise due to complexities in initializing such derived generic types. To overcome this, you can create a non-generic wrapper class for deserialization or use custom deserialization methods to handle the process, avoiding direct deserialization of the derived generic type. Alternatively, consider refactoring the classes or employing third-party libraries like Newtonsoft.Json (Json.NET) which often handle derived generic types more seamlessly during deserialization, offering a smoother and exception-free deserialization process. You can aswell desrialize to ViewModel Class..
14 replies
β (MVC web app) How can I handle exceptions/errors in this case?
In the provided AddTransaction method, it seems there's a need for improvements related to asynchronous operations, exception handling, and code structure. Here's an enhanced version with comments to illustrate some changes:
24 replies
β β
Mind explaining a code to me?
So, by finding the values with the closest absolute value to zero, the function determines which number or numbers are closest to zero, considering both positive and negative numbers equally in their proximity to zero. If there's a unique value that's closest to zero, the function returns that value. If multiple values share the same closest absolute distance to zero, it indicates that there's no singular closest value to zero, so the function returns None.
132 replies