mercredi 23 octobre 2019

Adding checkbox list of features in creating a new Car class

I'm developing something like portal for adding car ads. I really can't understand how to add a checkbox list to add in my AudiCarModel Class. I have all the properties for creating a new object, but i want to add different features which are able to be added. I need help i my AudiModelCar Class, some kind of a new class or enum or just list in the Controller. And create view code to implement it, of course

I've tried with enum class but it didn't happen

public class AudiCarModel
{
    [Key]
    public int AudiId { get; set; }


    [Required(ErrorMessage = "Моля, въведете категория")]
    [Display(Name = "Категория")]
    public AudiCategory AudiCategory { get; set; }


    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете модел")]
    [Display(Name = "Модел")]
    public AudiModel AudiModel { get; set; }


    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете цена")]
    [Display(Name = "Цена")]
    public decimal AudiPrice { get; set; }


    [Required(ErrorMessage = "Моля, въведете тип двигател")]
    [Display(Name = "Двигател")]
    public AudiEngineType AudiEngineType { get; set; }

    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете обем на двигателя")]
    [Display(Name = "Обем")]
    public double AudiCubics { get; set; }

    [DataType(DataType.Text)]
    [Required(ErrorMessage = "Моля, въведете конски сили")]
    [Display(Name = "HP")]
    public int AudiHP { get; set; }


    [Required(ErrorMessage = "Моля, въведете година")]
    [Display(Name = "Година")]
    public AudiYearProduced AudiYearProduced { get; set; }


    [Required(ErrorMessage = "Моля, въведете тип скоростна кутия")]
    [Display(Name = "Скоростна кутия")]
    public AudiTransmission AudiTransmission { get; set; }


    public List<FeatureEnumModel> CheckBoxFeatures { get; set; }
    //I accept any new approach - not enum, list of features is ok!

    [Required(ErrorMessage = "Моля, въведете населено място")]
    [Display(Name = "Населено място")]
    public AudiLocation AudiLocation { get; set; }

    [Required(ErrorMessage = "Моля, въведете телефонен номер")]
    [Display(Name = "Телефон")]
    public int PhoneNumber { get; set; }

    [Required(ErrorMessage = "Моля, въведете електронна поща")]
    [Display(Name = "Електронна поща")]
    public string Email { get; set; }

}

}

I need some help in the Controller Create(action), and in the Create(view).




Aucun commentaire:

Enregistrer un commentaire