Base solution for your next web application

Activities of "florinciubuc"

Hello. I have a question: Even though my model is inheriting IInputDto, ICustomValidate and i am overriding AddValidationErrors, the method cannot be reached.

This is my model:

[AutoMap(typeof(DataklasProjectTracking.Core.MasterData.Department))] public class DepartmentModel : IInputDto, ICustomValidate { public int Id { get; set; } public long? TenantId { get; set; } [Required] public string DepartmentName { get; set; } public bool IsActive { get; set; } public string Observations { get; set; } public bool IsDeleted { get; set; } public long? DeletedById { get; set; } public DateTime? DeletedOn { get; set; } public DateTime? UpdatedOn { get; set; } public long? UpdatedById { get; set; } public DateTime CreatedOn { get; set; } public long? CreatedById { get; set; }

    public void AddValidationErrors(List<ValidationResult> results)
    {
        if (DepartmentName.Length < 5)
        {
            results.Add(new ValidationResult("Department name is too short"));
        }
    }

As you can see, i use AutoMapper to convert data from Department entity to my model

Here is Department entity:

[Table("Department")]
public partial class Department : FullAuditedEntity<long>, IMayHaveTenant, IPassivable
{
    public virtual long? TenantId { get; set; }
    public virtual string DepartmentName { get; set; }
    public virtual bool IsActive { get; set; }
    public virtual string Observations { get; set; }

    [ForeignKey("DeletedById")]
    public virtual vwUser DeletedBy { get; set; }

    [ForeignKey("CreatedById")]
    public virtual vwUser CreatedBy { get; set; }

    [ForeignKey("UpdatedById")]
    public virtual vwUser UpdatedBy { get; set; }
}

What is wrong with my code? PS: Sorry for my bad english.

Thank you in advance, Florin Ciubuc

Showing 1 to 1 of 1 entries