C# ASP.NET MVC Forms Adding Form Validation Adding Server-Side Validations Using Data Annotations

Calvin Secrest
Calvin Secrest
24,160 Points

Bummer! Did you remove or change the Issue class?

In Issue.cs make the Name and DescriptionOfProblem properties required by adding [Required] data annotations to those properties.

Not sure if I did this challenge right?

Issue.cs
using System.ComponentModel.DataAnnotations;

namespace IssueReporter.Models
{
    public class Issue
    {
        public enum SeverityLevel
        {
            Minor,
            Major,
            Critical
        }

        public int Id { get; set; }
        public string Name { get; set; }
        public string Email { get; set; }
        [Required]
        [Display(Name = "Department")]
        public int DepartmentId { get; set; }
        public Department Department { get; set; }
        public SeverityLevel Severity { get; set; }
        public bool Reproducible { get; set; }
        [Required]
        [Display(Name = "Description of Problem")]
        public string DescriptionOfProblem { get; set; }
    }
}

1 Answer

Steven Parker
Steven Parker
203,121 Points

:point_right: You can be sure your answer is not right when you see "Bummer!". :smile:

You got the DescriptionOfProblem part right, but the challenge also asked you to make the Name property required. You appear to have made DepartmentId required instead.

Calvin Secrest
Calvin Secrest
24,160 Points

Thanks again for you response and assistance