コード例 #1
0
        public async Task <bool> AddSubscription(SubcsriptionModel model)
        {
            var subscribtion = new Subscription()
            {
                Email        = model.Email,
                Category     = model.Category,
                SubscribeAll = model.SubscribeAll,
                Created      = DateTime.UtcNow
            };

            bool result = await _subscriptionRepository.InsertSubscriptionAsync(subscribtion);

            return(result);
        }
コード例 #2
0
        public async Task <ActionResult> AddSubsctiption(SubcsriptionModel model)
        {
            if (string.IsNullOrWhiteSpace(model.Email))
            {
                return(BadRequest("You shuold provide valid email"));
            }

            bool result = await _subscriptionService.AddSubscription(model);

            if (result)
            {
                return(Ok("You subscribed to news!"));
            }

            return(BadRequest("Something went wrong!"));
        }