Base solution for your next web application

Activities of "adamphones"

it-s en-GB.

Thanks I managed to install the nuget package.

Thanks for coming back.

We use angular + asp net core.

Somehow the message we get contains square brackets. I think this indicates that the message is also localized.

However, we add those keys in the localization xml files we still don't get the message you get in the screenshot. Any idea on that?

And thanks for the Fluent Validation. I think this would be the way to go. However, the nuget package does not seem to install. I get the following message.

And I assume this would work which project this should be installed? .Core or better in .Application?

Regards,

version: asp zero 8.1 angular

`public class Schedule{

public DateTime EffectiveFrom {get;set;}

public DateTime EffectiveTo {get;set;} } ` We would like to enforce user to enter EndDate greater than StartDate. We tried ICustomValidate interface as below.

public void AddValidationErrors(CustomValidationContext context) { if (EffectiveTo.HasValue && EffectiveTo.Value.Date < EffectiveFrom.Date) { context.Results.Add(new ValidationResult("Effective To must be greater than Effective From date.")); } }

The validation seems work but on the client side we get an exception as 'Method arguments are not valid! See ValidationErrors for details.' But the client cannot really see which field has the issue or whether the EffectiveTo date should be greater than Effective From date.

One way to fix this issue would be to implement validation on angular in the client side. However we were wonder whether there is a better way to represent these validation issues to the client?

Regarding to this we could only see this document https://aspnetboilerplate.com/Pages/Documents/Validating-Data-Transfer-Objects#introduction-to-validation

Do you have any other documentation which explains data validation?

My second question which relates to this is that whether it is possible to generically create validations? What I mean by this is that instead of having validation on each class to implement "AddValidationErrors" seperate that outside of the class. The reason being is that we have a lot of entities that has the properties EffectiveFrom and EffectiveTo and they all need validation as EffectiveTo> EffectiveFrom. It would be nice to have single validation for those properties and automatically plug it into each class through interface maybe? Any idea on this?

I would appriciate your help on this topic.

Regards,

What we would like is to be able to send friendly message back to client for all Microsoft.EntityFrameworkCore.DbUpdateException instead of sending back 500 invalid exception message : "An error occurred while updating the entries. See the inner exception for details."

Showing 51 to 54 of 54 entries