Exemplo n.º 1
0
        private IEnumerable <string> GetExistingSalesAreas()
        {
            if (_existingSalesAreas == null || !_existingSalesAreas.Any(s => !string.IsNullOrWhiteSpace(s)))
            {
                _existingSalesAreas = _salesAreaRepository?.GetListOfNames();
            }

            return(_existingSalesAreas);
        }
        protected bool ContainOnlyExistingSalesAreas(List <SalesAreaPriorityModel> salesAreaPriorities)
        {
            _nonExistingSalesAreas = null;
            if (salesAreaPriorities != null && salesAreaPriorities.Count > 0)
            {
                var existingSalesAreaNames   = _salesAreaRepository.GetListOfNames();
                var salesAreaNamesToValidate = salesAreaPriorities.Where(a => !string.IsNullOrWhiteSpace(a.SalesArea))
                                               .Select(a => a.SalesArea.Trim()).Distinct().ToList();

                if (existingSalesAreaNames != null && existingSalesAreaNames.Count > 0)
                {
                    _nonExistingSalesAreas = salesAreaNamesToValidate.Except(existingSalesAreaNames).ToList();
                }
            }

            return(_nonExistingSalesAreas == null || _nonExistingSalesAreas.Count == 0);
        }