private List <SelectListItem> GetColorType() { ColorTypeFilter filter = new ColorTypeFilter(); filter.Name = ""; return(ColorTypeService.Get(filter).Select(b => new SelectListItem(b.Name, b.Id.ToString())).ToList()); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { List <ValidationResult> validationResult = new List <ValidationResult>(); if (string.IsNullOrWhiteSpace(this.Name)) { validationResult.Add(new ValidationResult("Name is required", new List <string> { "Name" })); } if (string.IsNullOrWhiteSpace(this.Code)) { validationResult.Add(new ValidationResult("Code is required", new List <string> { "Code" })); } if (validationResult.Count.Equals(0)) { /* Service Validation */ ColorTypeService service = (ColorTypeService)validationContext.GetService(typeof(ColorTypeService)); if (service.DbContext.Set <LampStandard>().Count(r => r._IsDeleted.Equals(false) && r.Id != this.Id && r.Code.Equals(this.Code)) > 0) /* Code Unique */ { validationResult.Add(new ValidationResult("Code already exists", new List <string> { "Code" })); } if (service.DbContext.Set <LampStandard>().Count(r => r._IsDeleted.Equals(false) && r.Id != this.Id && r.Name.Equals(this.Name)) > 0) /* Name Unique */ { validationResult.Add(new ValidationResult("Name already exists", new List <string> { "Name" })); } } return(validationResult); }
private List <SelectListItem> GetColorTypes() { return(ColorTypeService.Get(new ColorTypeFilter()).Select(c => new SelectListItem(c.Name, c.Id.ToString())).ToList()); }