public override ValidationResult Validate(ComponentOrderRequestDto entity) { var validationResult = new ValidationResult(); var components = _componentRepository.GetComponents().Select(e => e.Id).ToHashSet(); if (entity.ComponentIds.Any(e => !components.Contains(e))) { var missingComponents = entity.ComponentIds.Where(e => !components.Contains(e)); foreach (var missingComponent in missingComponents) { validationResult.Errors.Add($"Component with id {missingComponent} is not found!"); } } return(validationResult); }
public List <AdminComponentModel> GetComponents(int productId, int productVerionsId) { var components = componentRepository.GetComponents(productVerionsId); var adminComponents = new List <AdminComponentModel>(); foreach (var component in components) { adminComponents.Add(new AdminComponentModel() { Id = component.Id, Description = component.Description, Name = component.Name, TagName = component.TagName, AddAtVersion = component.Versions.OrderByDescending(x => x.ProductVersion.PublishTime).FirstOrDefault()?.ProductVersion.Version }); } return(adminComponents); }
public IEnumerable <ComponentResponseDto> GetComponents() { var components = _repository.GetComponents(); return(_mapper.Map <IEnumerable <ComponentResponseDto> >(components)); }
public async Task <ActionResult <Component> > GetComponents() { var product = await _repository.GetComponents(); return(Ok(product)); }
public ActionResult <IEnumerable <Component> > Get() { return(Ok(_componentRepository.GetComponents())); }
public IEnumerable <Repository.Model.Component> GetComponents(int versionId) { return(componentRepository.GetComponents(versionId)); }