public void _Should_Set_description_Correctly(int id, string title, string description, CategoryEnum categoryEnum) { //Arrange var Post = new Post(); var category = new Category(); var mockedPostRepository = new Mock <IRepository <Post> >(); mockedPostRepository.Setup(r => r.GetById(It.IsAny <int>())).Returns(Post); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); mockedCategoryService.Setup(m => m.GetCategoryByName(It.IsAny <CategoryEnum>())).Returns(category); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); //Act postService.EditPost(id, title, description, categoryEnum); //Assert Assert.AreEqual(Post.Description, description); }
public void _Call_PostRepository_Update(int id, string title, string description, CategoryEnum categoryEnum) { //Arrange var Post = new Post(); var category = new Category(); var mockedPostRepository = new Mock <IRepository <Post> >(); mockedPostRepository.Setup(r => r.GetById(It.IsAny <int>())).Returns(Post); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); mockedCategoryService.Setup(m => m.GetCategoryByName(It.IsAny <CategoryEnum>())).Returns(category); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); //Act postService.EditPost(id, title, description, categoryEnum); //Assert mockedPostRepository.Verify(r => r.Update(Post), Times.Once); }
public void ImportCSVTest() { PostsService service = new PostsService(); List <PostsModels> posts = service.ImportCSV(filePath); Assert.AreEqual(posts.Count, 1985); }
public async Task GetImageByIdAsyncShouldThrowExceptionIfImageIsNull() { var options = new DbContextOptionsBuilder <MyCalisthenicAppDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()) .Options; var dbContext = new MyCalisthenicAppDbContext(options); IHttpContextAccessor httpContextAccessor = new HttpContextAccessor(); var usersService = new UsersService(httpContextAccessor, dbContext, null); var mockMapper = new MapperConfiguration(cfg => { cfg.AddProfile(new MyCalisthenicAppProfile()); }); var mapper = mockMapper.CreateMapper(); var categoriesService = new CategoriesService(dbContext, mapper); var postsService = new PostsService(dbContext, mapper, usersService, categoriesService); var productsService = new ProductsService(dbContext, mapper, usersService, categoriesService); var programsService = new ProgramsService(dbContext, mapper, usersService, categoriesService); var exercisesService = new ExercisesService(dbContext, mapper, usersService, categoriesService); var imagesService = new ImagesService(dbContext, mapper, postsService, exercisesService, productsService, programsService); var exception = await Assert.ThrowsAsync <ArgumentNullException>(async() => await imagesService.GetImageByIdAsync(ImageId)); Assert.IsType <ArgumentNullException>(exception); }
public HomeController(UnitOfWork unitOfWork) { _unitOfWork = unitOfWork; _postService = new PostsService(_unitOfWork); _usersService = new UsersService(_unitOfWork); _tagsService = new TagsService(_unitOfWork); }
public void Init() { usersRepository = TestObjectsFactory.GetUsersRepository(); threadsRepository = TestObjectsFactory.GetThreadsRepository(); postsRepository = TestObjectsFactory.GetPostsRepository(); this.service = new PostsService(postsRepository, usersRepository, threadsRepository); }
public CommentsController(UnitOfWork unitOfWork) { _unitOfWork = unitOfWork; _service = new CommentsService(_unitOfWork); _usersService = new UsersService(_unitOfWork); _postsService = new PostsService(_unitOfWork); }
public PostsServiceTests() { AutoMapperConfig.RegisterMappings(Assembly.Load("HiWorld.Services.Data.Tests")); var mockImageService = new Mock <IImagesService>(); mockImageService.Setup(x => x.CreateAsync(It.IsAny <IFormFile>(), It.IsAny <string>())) .Returns(Task.Run(() => "test")); this.imagesService = mockImageService.Object; var mockTagService = new Mock <ITagsService>(); mockTagService.Setup(x => x.GetIdAsync(It.IsAny <string>())) .Returns(Task.Run(() => 1)); this.tagsService = mockTagService.Object; var connection = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()); this.dbContext = new ApplicationDbContext(connection.Options); this.dbContext.Database.EnsureCreated(); this.postsRepository = new EfDeletableEntityRepository <Post>(this.dbContext); this.postTagsRepository = new EfRepository <PostTag>(this.dbContext); this.postLikesRepository = new EfRepository <PostLike>(this.dbContext); this.postsService = new PostsService( this.postsRepository, this.postTagsRepository, this.postLikesRepository, this.imagesService, this.tagsService); }
public void TestEditPostNegative() { PostsService service = new PostsService(); PostsController controller = new PostsController(service); controller.Put(""); }
public async Task CreateAsync_WithValidData_ShouldAddToDatabase() { // Arrange var context = InMemoryDbContext.Initiliaze(); var postRepository = new EfDeletableEntityRepository <Post>(context); var postService = new PostsService(postRepository); // Act var model = new PostCreateModel { CreatorId = "creatorIdStringUnique", Description = "descriptionrandom", }; await postService.CreateAsync(model, "urltoimg.com", "dsahu2171dyh"); int expectedCount = postRepository.All().Count(); int actualCount = postRepository.All().Count(); var expectedPost = model; var actualPost = postRepository.All().FirstOrDefault(); // Assert Assert.Equal(expectedCount, actualCount); Assert.True(expectedPost.Description == actualPost.Description); Assert.True(expectedPost.CreatorId == actualPost.CreatorId); }
public void GetUserByPostIdShouldWorkCorrectly() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new PostsService(null, mockPostRepo.Object); var post = new Post { Id = "1", UserId = "1", Content = "Test", Title = "Test", SentById = "1", }; posts.Add(post); var userId = service.GetPostById("1"); var expectedOutput = "1"; Assert.Equal(expectedOutput, userId); }
public void TestDeletePostNegative() { PostsService service = new PostsService(); PostsController controller = new PostsController(service); controller.Delete(-1); }
// GET: api/Posts public IEnumerable <Post> Get() { PostsService postsService = new PostsService(); IEnumerable <Post> posts = postsService.GetAllPosts(); return(posts); }
public void _Call_CategoryService_GetCategoryByName( string userId, string title, string text, string coverPicture, CategoryEnum categoryEnum) { //Arrange var mockedPostRepository = new Mock <IRepository <Post> >(); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); //Act postService.CreatePost(userId, title, text, coverPicture, categoryEnum); //Assert mockedCategoryService.Verify(c => c.GetCategoryByName(categoryEnum), Times.Once); }
public async Task GetSchoolShouldReturnSchoolViewModel() { var dbOptions = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase("test"); var context = new ApplicationDbContext(dbOptions.Options); var commentsService = new CommentsService(context); var postsService = new PostsService(context, commentsService); var schoolService = new SchoolService(context, postsService); var school = new School() { Name = "test" }; var user = new ApplicationUser() { SchoolId = school.Id }; await context.Schools.AddAsync(school); await context.Users.AddAsync(user); await context.SaveChangesAsync(); var result = schoolService.GetSchool(user, 0); Assert.That(result != null); }
public async Task GetAuthorIdByIdMethodShouldReturnNullIfPostIsDeleted() { var options = new DbContextOptionsBuilder <ForumDbContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var db = new ForumDbContext(options); var dateTimeProvider = new Mock <IDateTimeProvider>(); dateTimeProvider.Setup(dtp => dtp.Now()).Returns(new DateTime(2020, 3, 27)); var post = new Post { Id = 1, Title = "Test title 1", Description = "Test description 1", Type = PostType.Discussion, CategoryId = 1, AuthorId = "Test author id", IsDeleted = true, CreatedOn = dateTimeProvider.Object.Now(), DeletedOn = dateTimeProvider.Object.Now() }; await db.Posts.AddAsync(post); await db.SaveChangesAsync(); var postsService = new PostsService(db, null, null, dateTimeProvider.Object); var authorId = await postsService.GetAuthorIdByIdAsync(1); authorId.Should().BeNull(); }
public async Task EditPostAsyncShouldWorkCorrectly() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new PostsService(null, mockPostRepo.Object); var post = new Post { Id = "1", UserId = "1", Content = "Test", Title = "Test", SentById = "1", }; posts.Add(post); await service.EditPost("1", "newContent", "newTitle", "1"); Assert.Equal("newContent", post.Content); Assert.Equal("newTitle", post.Title); }
public async Task CreateMethodShouldAddPostInDatabase(string title, PostType type, string description, int categoryId) { var guid = Guid.NewGuid().ToString(); var options = new DbContextOptionsBuilder <ForumDbContext>() .UseInMemoryDatabase(guid) .Options; var db = new ForumDbContext(options); var dateTimeProvider = new Mock <IDateTimeProvider>(); var usersServiceMock = new Mock <IUsersService>(); dateTimeProvider.Setup(dtp => dtp.Now()).Returns(new DateTime(2020, 3, 27)); usersServiceMock.Setup(us => us.AddPointsAsync(guid, 1)).ReturnsAsync(1); var postsService = new PostsService(db, null, usersServiceMock.Object, dateTimeProvider.Object); var expectedIds = new[] { 1, 2, 3 }; var postId = await postsService.CreateAsync(title, type, description, guid, categoryId, expectedIds); var actual = await db.Posts.FirstOrDefaultAsync(); var actualTagIds = actual.Tags.Select(t => t.TagId).ToArray(); postId.Should().Be(1); db.Posts.Should().HaveCount(1); actualTagIds.Should().BeEquivalentTo(expectedIds); }
public async Task IsExistingMethodShouldReturnTrueIfPostExists() { var guid = Guid.NewGuid().ToString(); var options = new DbContextOptionsBuilder <ForumDbContext>() .UseInMemoryDatabase(guid) .Options; var db = new ForumDbContext(options); var dateTimeProvider = new Mock <IDateTimeProvider>(); dateTimeProvider.Setup(dtp => dtp.Now()).Returns(new DateTime(2020, 3, 27)); var post = new Post { Id = 1, Title = "Test title", Description = "Test description", Type = PostType.Discussion, CategoryId = 1, AuthorId = guid, CreatedOn = dateTimeProvider.Object.Now() }; await db.Posts.AddAsync(post); await db.SaveChangesAsync(); var postsService = new PostsService(db, null, null, dateTimeProvider.Object); var isExisting = await postsService.IsExistingAsync(1); isExisting.Should().BeTrue(); }
public void _Call_UnitOfWork_Commit(int id) { //Arrange var post = new Post(); var mockedPostRepository = new Mock <IRepository <Post> >(); mockedPostRepository.Setup(r => r.GetById(It.IsAny <int>())).Returns(post); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); var comment = new Comment(); //Act postService.AddComment(id, comment); //Assert mockedUnitOfWork.Verify(u => u.Commit(), Times.Once); }
public void _Call_PostRepository_GetById(int id) { //Arrange var mockedPostRepository = new Mock <IRepository <Post> >(); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); var comment = new Comment(); //Act postService.AddComment(id, comment); //Assert mockedPostRepository.Verify(r => r.GetById(id), Times.Once); }
public void _Return_Correct_Instance(int id) { //Arrange var mockedPost = new Mock <Post>(); var mockedPostRepository = new Mock <IRepository <Post> >(); mockedPostRepository.Setup(r => r.GetById(It.IsAny <object>())).Returns(mockedPost.Object); var mockedUserService = new Mock <IUserService>(); var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedPostFactory = new Mock <IPostFactory>(); var mockedCategoryService = new Mock <ICategoryService>(); var mockedDateTimeProvider = new Mock <IDateTimeProvider>(); var postService = new PostsService( mockedPostRepository.Object, mockedUserService.Object, mockedUnitOfWork.Object, mockedPostFactory.Object, mockedCategoryService.Object, mockedDateTimeProvider.Object); //Act var res = postService.GetPostById(id); //Assert Assert.IsInstanceOf <Post>(res); }
public void IsUserCreatorOfPostShouldReturnFalse() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new PostsService(null, mockPostRepo.Object); var post = new Post { Id = "1", UserId = "1", Content = "Test", Title = "Test", SentById = "2", }; posts.Add(post); var result = service.IsUserCreatorOfPost("1", "1"); Assert.Equal(false, result); }
public async Task GetLatestActivityByIdMethodShouldReturnPostLatestActivity() { var guid = Guid.NewGuid().ToString(); var options = new DbContextOptionsBuilder <ForumDbContext>() .UseInMemoryDatabase(guid) .Options; var db = new ForumDbContext(options); var dateTimeProvider = new Mock <IDateTimeProvider>(); dateTimeProvider.Setup(dtp => dtp.Now()).Returns(new DateTime(2020, 3, 27)); var post = new Post { Id = 1, Title = "Test title 1", Description = "Test description 1", Type = PostType.Discussion, CategoryId = 1, AuthorId = guid, CreatedOn = dateTimeProvider.Object.Now(), }; await db.Posts.AddAsync(post); await db.SaveChangesAsync(); var postsService = new PostsService(db, null, null, dateTimeProvider.Object); var latestActivity = await postsService.GetLatestActivityByIdAsync(1); latestActivity.Should().Be("0m"); }
public async Task GetByUserIdShouldReturnCount2() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new PostsService(null, mockPostRepo.Object); var post = new Post { Id = "1", UserId = "1", }; var secondPost = new Post { Id = "2", UserId = "1", }; posts.Add(post); posts.Add(secondPost); var postsCount = service.GetByUserId <PostsViewModel>("1"); var expectedResult = 2; Assert.Equal(expectedResult, postsCount.Count()); }
public void GetByIdIdShouldReturnCorrectPost() { var mockRepo = new Mock <IDeletableEntityRepository <Post> >(); mockRepo.Setup(x => x.All()) .Returns(new List <Post>() { new Post { Id = 1, Content = "Test", Title = "Test", CategoryId = 1, Category = new Category(), UserId = "Test", User = new ApplicationUser(), }, new Post { Id = 2, Content = "Test2", Title = "Test2", CategoryId = 1, Category = new Category(), UserId = "Test2", User = new ApplicationUser(), }, }.AsQueryable()); var service = new PostsService(mockRepo.Object); var result = service.GetById <PostViewModel>(2); Assert.Equal("Test2", result.Title); }
public async Task EditPostAsyncShouldReturnFalse() { var posts = new List <Post>(); var mockPostRepo = new Mock <IDeletableEntityRepository <Post> >(); mockPostRepo.Setup(x => x.All()).Returns(posts.AsQueryable()); mockPostRepo.Setup(x => x.AddAsync(It.IsAny <Post>())).Callback((Post post) => posts.Add(post)); var service = new PostsService(null, mockPostRepo.Object); var post = new Post { Id = "1", UserId = "1", Content = "Test", Title = "Test", SentById = "2", }; posts.Add(post); Task result = service.EditPost("1", "newContent", "newTitle", "1"); Assert.False(result.IsFaulted); }
public void TestEditPostPositive() { PostsService service = new PostsService(); PostsController controller = new PostsController(service); controller.Put("{'text': 'new same text', 'id': '2'}"); }
public void TestAddPostPositive() { PostsService service = new PostsService(); PostsController controller = new PostsController(service); controller.Post("{'text': 'same text', 'authorId': '1'}"); }
public void TestGetPostNegative() { PostsService service = new PostsService(); PostsController controller = new PostsController(service); string result = controller.Get(-1); }
public void TestGetPosts() { PostsService service = new PostsService(); PostsController controller = new PostsController(service); controller.Get(); }
/// <remarks> /// ScheduledAgent constructor, initializes the UnhandledException handler /// </remarks> public ScheduledAgent() { if (!_classInitialized) { _classInitialized = true; // Subscribe to the managed exception handler Deployment.Current.Dispatcher.BeginInvoke(delegate { Application.Current.UnhandledException += ScheduledAgent_UnhandledException; }); var vdpContext = new VDPContext(); postService = new PostsService(vdpContext); } }
private static void Seed() { CategoriesService categories = new CategoriesService(); categories.Add("Programming"); categories.Add("CSharp"); categories.Add("JavaScript"); categories.Add("Hobbies"); var all = categories.All().ToList(); foreach (var cat in all) { Console.WriteLine(cat.CategoryName); } PostsService posts = new PostsService(); posts.Add("Zopfli Optimization: Literally Free Bandwidth", "In 2007 I wrote about using PNGout to produce amazingly small PNG images. I still refer to this topic frequently, as seven years later, the average PNG I encounter on the Internet is very unlikely to be optimized. ", "*****@*****.**", new List<int>() { 1 }); posts.Add("The Hugging Will Continue Until Morale Improves", "I saw in today's news that Apple open sourced their Swift language. One of the most influential companies in the world explicitly adopting an open source model – that's great! I'm a believer. One of the big reasons we founded Discourse was to build an open source solution that anyone, anywhere could use and safely build upon.", "*****@*****.**", new List<int>() { 2 }); posts.Add("The 2016 HTPC Build", "I saw in today's news that Apple open sourced their Swift language. One of the most influential companies in the world explicitly adopting an open source model – that's great! I'm a believer. One of the big reasons we founded Discourse was to build an open source solution that anyone, anywhere could use and safely build upon.", "*****@*****.**", new List<int>() { 1 }); posts.Add("10 Years of CodeMash", @"I spent this past week at the 10th annual CodeMash conference in Sandusky OH. Every single event has been enjoyable, envigorating, and a great way to kick-start the year. The event has changed dramatically over the past decade, but it still has the same core values from when it was started. It’s a group of people passionate about technology in many incarnations, and willing to share and learn from each other. Looking back at 10 years of CodeMash, several larger trends appear. Early on, the languages discussed most were Java, C#, VB.NET, and Python. Over time, more and more interest in Ruby grew. Java waned for a time. Functional languages like F#, Haskell, and Erlang became more popular. There were a few Scala sessions.", "*****@*****.**", new List<int>() { 2 }); posts.Add("Milk + Soap + Food Coloring = Awesome Reaction", @" Food coloring will allow you to see what is actually happening and create beautiful swirls and patterns. Any kind, color or amount will work. Have fun experimenting! To hold the milk, use a shallow bowl or a plate with raised edges. Regular old dish soap is the way to go. Finally some Q-tips to apply the soap with.", "*****@*****.**", new List<int>() { 4 }); }
public void GetPosts(HttpContext context) { ZwJson zwJson = new ZwJson(); ISession session = SessionFactory.GetCurrentSession(); PostsService posts = new PostsService(session); var pageStart = int.Parse(context.Request.Params["current"] ?? "1"); var pageLimit = int.Parse(context.Request.Params["total"] ?? "10"); var count = 0; var list = posts.FindByPosts(pageStart, pageLimit, ref count); zwJson.IsSuccess = true; zwJson.Data = list; zwJson.Other = count.ToString(); zwJson.JsExecuteMethod = "ajax_GetPosts"; context.Response.Write(_jss.Serialize(zwJson)); }
public void GetUserPostsById(HttpContext context) { ZwJson zwJson = new ZwJson(); PostsService postsService = new PostsService(_session); UserPostsService userPostsService = new UserPostsService(_session); var postid = context.Request.Params["postid"]; var list2 = postsService.FindById2(postid); list2.ReplyCount = list2.UserPostses.Count; zwJson.Other = list2.ReplyCount.ToString(); postsService.SaveOrUpdate(list2); Posts posts = new Posts() { Id = postid }; var list = userPostsService.FindById(posts); zwJson.IsSuccess = true; zwJson.Data = list; zwJson.JsExecuteMethod = "ajax_GetUserPostsById"; context.Response.Write(_jss.Serialize(zwJson)); }
/// <summary> /// 删除帖子 /// </summary> /// <param name="context"></param> public void DelPosts(HttpContext context) { ZwJson zwJson = new ZwJson(); PostsService postsService = new PostsService(_session); UserService userService = new UserService(_session); var id = context.Request.Params["id"]; var name = context.Session["UserName"]; if (name != null) { postsService.Delete(new Posts { Id = id }); zwJson.IsSuccess = true; zwJson.JsExecuteMethod = "ajax_DelPosts"; } else { zwJson.IsSuccess = false; zwJson.Msg = "请先登录!"; } context.Response.Write(_jss.Serialize(zwJson)); }
/// <summary> /// 保存post数据 /// </summary> /// <param name="context"></param> public void SavePosts(HttpContext context) { ZwJson zwJson = new ZwJson(); PostsService postsService = new PostsService(_session); UserService userService = new UserService(_session); var title = context.Request.Params["title"]; var khtml = context.Request.Params["khtml"]; var name = context.Session["UserName"]; if (name != null) { var data = userService.FindByName(name.ToString()); postsService.Save(new Posts() { Id = Guid.NewGuid().ToString(), Contents = khtml, CreateDt = DateTime.Now, Title = title, ViewCount = 0, ReplyCount = 0, User = data[0] }); zwJson.IsSuccess = true; zwJson.JsExecuteMethod = "ajax_SavePosts"; } else { zwJson.IsSuccess = false; zwJson.Msg = "请先登录!"; } context.Response.Write(_jss.Serialize(zwJson)); }