public IHttpActionResult Get(int id)
        {
            var item = _repository.Get(id);

            if (item == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <DeliveryCappingGroupModel>(item)));
        }
Beispiel #2
0
        /// <summary>
        /// Validate CampaignRunProcessesSettingsModel list
        /// DeliveryCappingGroupIds vs existing DeliveryCappingGroupIds
        /// </summary>
        /// <param name="campaignRunProcessesSettings"></param>
        public void ValidateDeliveryCappingGroupIds(IEnumerable <CampaignRunProcessesSettingsModel> campaignRunProcessesSettings)
        {
            var deliveryCappingGroupsIds = campaignRunProcessesSettings
                                           .Where(x => x.DeliveryCappingGroupId != 0)
                                           .Select(x => x.DeliveryCappingGroupId)
                                           .Distinct();

            if (!deliveryCappingGroupsIds.Any())
            {
                return;
            }

            var existingsDeliveryCappingGroupIds = _deliveryCappingGroupRepository.Get(deliveryCappingGroupsIds).Select(x => x.Id);

            var invalidDeliveryCappingGroupIds = deliveryCappingGroupsIds.Except(existingsDeliveryCappingGroupIds);

            if (invalidDeliveryCappingGroupIds.Any())
            {
                throw new ArgumentException($"Invalid delivery capping groups ids: {string.Join(", ", invalidDeliveryCappingGroupIds)}");
            }
        }