예제 #1
0
        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);
        }
예제 #2
0
        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);
        }
예제 #3
0
        public IEnumerable <ComponentResponseDto> GetComponents()
        {
            var components = _repository.GetComponents();

            return(_mapper.Map <IEnumerable <ComponentResponseDto> >(components));
        }
예제 #4
0
        public async Task <ActionResult <Component> > GetComponents()
        {
            var product = await _repository.GetComponents();

            return(Ok(product));
        }
예제 #5
0
 public ActionResult <IEnumerable <Component> > Get()
 {
     return(Ok(_componentRepository.GetComponents()));
 }
예제 #6
0
 public IEnumerable <Repository.Model.Component> GetComponents(int versionId)
 {
     return(componentRepository.GetComponents(versionId));
 }