コード例 #1
0
        public virtual async void TestDelete()
        {
            var builder = new WebHostBuilder()
                          .UseEnvironment("Production")
                          .UseStartup <TestStartup>();
            TestServer testServer = new TestServer(builder);
            var        client     = new ApiClient(testServer.CreateClient());

            client.SetBearerToken(JWTTestHelper.GenerateBearerToken());
            ApplicationDbContext context = testServer.Host.Services.GetService(typeof(ApplicationDbContext)) as ApplicationDbContext;

            IFollowerService service = testServer.Host.Services.GetService(typeof(IFollowerService)) as IFollowerService;
            var model = new ApiFollowerServerRequestModel();

            model.SetProperties("B", DateTime.Parse("1/1/1988 12:00:00 AM"), 1, 1, "B", "B");
            CreateResponse <ApiFollowerServerResponseModel> createdResponse = await service.Create(model);

            createdResponse.Success.Should().BeTrue();

            ActionResponse deleteResult = await client.FollowerDeleteAsync(2);

            deleteResult.Success.Should().BeTrue();
            ApiFollowerServerResponseModel verifyResponse = await service.Get(2);

            verifyResponse.Should().BeNull();
        }
コード例 #2
0
 public HttpResponseMessage AddFollower(FollowerModel followerModel)
 {
     if (followerModel != null)
     {
         var followerentity = new FollowerEntity
         {
             Openid        = followerModel.Openid,
             Nickname      = followerModel.Nickname,
             Sex           = followerModel.Sex,
             City          = followerModel.City,
             Country       = followerModel.Country,
             Private       = followerModel.Private,
             Language      = followerModel.Language,
             Headimgurl    = followerModel.Headimgurl,
             Subscribetime = followerModel.Subscribe_time,
             Unioid        = followerModel.Unioid,
             Remark        = followerModel.Remark,
             Groupid       = followerModel.Groupid,
             Adduser       = followerModel.Adduser,
             Addtime       = DateTime.Now,
             Upuser        = followerModel.Upuser,
             Uptime        = DateTime.Now
         };
         var phoneentity = new PhoneEntity
         {
             Follower = _followerService.Create(followerentity),
             Openid   = followerModel.Openid,
             Phone    = followerModel.Phone,
             Adduser  = followerModel.Adduser,
             Addtime  = DateTime.Now,
             Upuser   = followerModel.Upuser,
             Uptime   = DateTime.Now
         };
         try
         {
             _phoneService.Create(phoneentity);
             return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!")));
         }
         catch
         {
             return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")));
         }
     }
     return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据验证错误!")));
 }