Ejemplo n.º 1
0
        public async Task <Subscriber> MakeAsync(CreateSubscriberDto model)
        {
            model.CheckArgumentIsNull(nameof(model));
            var entity = new Subscriber {
                Email        = model.Email,
                Name         = model.Name,
                RegisterDate = _dateService.UtcNow(),
                Status       = SubscriberStatus.Enabled,
                WebsiteId    = _websiteInfo.Id
            };

            return(await Task.FromResult(entity));
        }
Ejemplo n.º 2
0
        public async Task <bool> ValidateCreateAsync(CreateSubscriberDto model)
        {
            model.CheckArgumentIsNull(nameof(model));

            //if (string.IsNullOrWhiteSpace(model.Name))
            //    throw new ArgumentNullException(nameof(model.Name));

            if (string.IsNullOrWhiteSpace(model.Email))
            {
                throw new ArgumentNullException(nameof(model.Email));
            }

            var subscriber = await _repository.FindByEmailAsync(model.Email);

            if (subscriber != null)
            {
                throw new SubscriptionEmailExistException();
            }

            return(await Task.FromResult(true));
        }