I'm trying to acheive the DRY principle by using OOP for my view models:

public class ItemBase
{
    [Display(Name = "Description - Displayed in the list (so make this meaningful)")]
    [Required]
    public string Description { get; set; }

    [Display(Name = "Username")]
    [Required]
    public string UserName { get; set; }

    [Display(Name = "Optional Secondary Credential")]
    public string SecondCredential { get; set; }

    [Display(Name = "Location - Ideally a URL")]
    [Required]
    public string Location { get; set; }

    [Display(Name = "Additional Notes")]
    public string Notes { get; set; }
}


public class ItemDisplay : ItemBase
{
    [Required]
    public Int32 ItemId { get; set; }
    public ApplicationUser Creator { get; set; }
}

public class ItemEdit : ItemBase
{
    [Required]
    public Int32 ItemId { get; set; }

}

public class ItemAdd : Itemase
{
    [Required]
    public Int32 Parent_CategoryId { get; set; }

}

This does work great... however, when I want to use the ItemDisplay class to display the data in the view, it displays the Display attribute data. How would I get the view to ignore these without putting all of the members into the ItemDisplay class without the Display attrbute?

Related posts

Recent Viewed