public async Task <ActionResult> GetSubscriptions(int id)
        {
            var Subscriptions = await _repo.GetSubscriptionsByIdAsync(id);

            var resource = ApiMapper.MapSub(Subscriptions);

            if (Subscriptions == null)
            {
                return(NotFound());
            }

            return(Ok(resource));
        }
コード例 #2
0
        public async Task <ActionResult> GetSubscriptions(int id)
        {
            try
            {
                if (await _repo.GetSubscriptionById(id) is CoreSubscriptions sub)
                {
                    var resource = ApiMapper.MapSub(sub);
                    return(Ok(resource));
                }
            }
            catch (NullReferenceException)
            {
                return(NotFound($"No Subscripttion with an id of {id} was found."));
            }

            return(Ok("There are no Subscriptions."));
        }
コード例 #3
0
        public void MapSub_StateUnderTest_ExpectedBehavior()
        {
            var apiMapper         = this.CreateApiMapper();
            CoreSubscriptions sub = new CoreSubscriptions
            {
                Company               = "company",
                Id                    = 1,
                Notification          = true,
                SubscriptionDate      = new DateTime(),
                SubscriptionDueDate   = new DateTime(),
                SubscriptionMonthCost = 1,
                SubscriptionName      = "name",
                UserId                = 1
            };
            var result = ApiMapper.MapSub(
                sub);

            Assert.True(true);
        }