Beispiel #1
0
        public override bool Validate(DashboardDto request)
        {
            if (!_repository.Exists(request.Id))
            {
                Errors.Add(new ErrorDto("404", "A Dashboard with such ID does not exist"));
            }

            var componentRepository = new DashboardComponentRepository();

            if (request.ComponentIds != null)
            {
                if (request.ComponentIds.Count > 0)
                {
                    foreach (var component in request.ComponentIds)
                    {
                        if (componentRepository.Exists(component))
                        {
                            continue;
                        }
                        Errors.Add(new ErrorDto("404",
                                                "A provided Dashboard Component with ID " + component + " does not exist"));
                    }
                }
            }

            if (Errors.Count == 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        public override DashboardResponse HandleCore(int request)
        {
            var          mapping             = new Mapping();
            DashboardDto toDelete            = mapping.DashboardToDto(_repository.Get(request));
            var          componentRepository = new DashboardComponentRepository();

            foreach (var id in toDelete.ComponentIds)
            {
                componentRepository.Remove(id);
            }
            _repository.Remove(request);
            return(new DashboardResponse(toDelete));
        }