When I try to Update IsApproved=true to approve the property, I am getting the following error. Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. The validation errors are: Please upload the image.; Please select some property features. Please help me out. Thanx in advance. My Model is as follows:
[Table("AddProperty")] public class AddProperty { [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] [HiddenInput(DisplayValue = false)] public int Id { get; set; }
public List<TransactionType> TransactionType_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "Please select the category.")]
[Display(Name = "Category:")]
public int TransactionTypeId { get; set; }//Used to post back selected value
public virtual TransactionType TransactionType { get; set; }
public List<PropertyType> PropertyType_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "Please select the property.")]
[Range(1, int.MaxValue, ErrorMessage = "Please select the property.")]
[Display(Name = "Property:")]
public int PropertyTypeId { get; set; }//Used to post back selected value
public virtual PropertyType PropertyType { get; set; }
public List<PropertyList> PropertyList_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "Please select the property type.")]
[Range(1, int.MaxValue, ErrorMessage = "Please select the property type.")]
[Display(Name = "Property Type:")]
public int PropertyListId { get; set; }//Used to post back selected value
public virtual PropertyList PropertyList { get; set; }
[Required(ErrorMessage = "Property Name is required.")]
[StringLength(50, MinimumLength = 3, ErrorMessage = "Building Name length should be between 3 and 50.")]
[Display(Name = "Property Name:")]
public string PropertyName { get; set; }
public List<FlatDescription> FlatDescription_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "Description is required.")]
[Display(Name = "Description:")]
public int FlatDescriptionId { get; set; }
public virtual FlatDescription FlatDescription { get; set; }
public List<Bathroom> Bathrooms_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "No of Bathrooms is required.")]
[Display(Name = "No of Bathrooms:")]
public int BathroomId { get; set; }//Used to post back selected value
public virtual Bathroom Bathroom { get; set; }
public List<City> City_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "Please select the city.")]
[Display(Name = "City:")]
public int CityId { get; set; }//Used to post back selected value
public virtual City City { get; set; }
[Required(ErrorMessage = "Location is required.")]
[StringLength(30, MinimumLength = 3, ErrorMessage = "Location length should be between 3 and 30.")]
[Display(Name = "Location:")]
public string Location { get; set; }
[Required(ErrorMessage = "Property Price is required.")]
[Range(typeof(decimal),"1","10000000",ErrorMessage = "Please enter valid property price.")]
[RegularExpression(@"^\d+.\d{0,2}$", ErrorMessage = "Only 2 decimal point values are allowed.")]
[Display(Name = "Enter Property Price:")]
public decimal PropertyPrice { get; set; }
//[Required(ErrorMessage = "Please upload the image.")]
[Display(Name = "Upload Image:")]
[NotMapped]
[ValidatePhoto]
public HttpPostedFileBase PropertyPhoto { get; set; }
public string ImageURL { get; set; }
public List<Facilities> Facilities_List { get; set; }//Used to populate dropdown list values
[Required(ErrorMessage = "Please select some property features.")]
[Display(Name = "Select Property Features:")]
[NotMapped]
public int[] SelectedIds { get; set; }//Used to post back selected value
public string PropertyFeatures { get; set; }
[HiddenInput(DisplayValue = false)]
public DateTime CreateDate { get; set; }
[HiddenInput(DisplayValue = false)]
public DateTime? UpdateDate { get; set; }
[HiddenInput(DisplayValue = false)]
public int CreateUser { get; set; }
[HiddenInput(DisplayValue=false)]
public int? UpdateUser { get; set; }
[HiddenInput(DisplayValue = false)]
public bool IsApproved { get; set; }
[HiddenInput(DisplayValue = false)]
public bool IsActive { get; set; }
}