예제 #1
0
        public ActionResult AddAppProjectTag(string appProjectId, string tagName, int? page)
        {
            var checkReduplicateRes = UIService.GetTagIdByName(tagName);
            if (string.IsNullOrEmpty(checkReduplicateRes))
            {
                return Json(string.Empty);
            }
            var currentTag = new Tag();
            if (!string.IsNullOrEmpty(tagName.Trim()) && !IsSysReservedTagName(tagName))
            {
                var tagId = UIService.AddTagForAppProject(tagName, appProjectId);

                var tags = UIService.GetTagsByAppProject(appProjectId);

                currentTag = tags.SingleOrDefault(x => x.Id.Equals(tagId));
            }
            return Json(currentTag);
        }
        public void get_tag_list_test_normal()
        {
            #region Generate Data
            string lcd = "320x480";

            #region app and tags

            var sortedTags = new List<Tag>();
            var tag1 = new Tag()
            {
                Id = "1",
                Name = "工具",
                OrderNumber = 4
            };
            var tag2 = new Tag()
            {
                Id = "2",
                Name = "娱乐",
                OrderNumber = 6
            };

             var tagIds = new List<string>{
                "1",
                "2"
            };

             var tagIdsSortedByOrderNumber = new List<string> { "2", "1" };

             sortedTags.Add(tag2);
             sortedTags.Add(tag1);

            App app1 = new App()
            {
                AppNo = "1",
                AppProjectId = "1",
                //ClientLogos="",
                CurrentVer = "1",
                Id = "1",
                Name = "app1",
                Price = 0.0,
                Rank = 3,
                ReviewCount = 3

            };
            App app2 = new App()
            {
                AppNo = "2",
                AppProjectId = "2",
                //ClientLogos="",
                CurrentVer = "2",
                Id = "2",
                Name = "app2",
                Price = 0.0,
                Rank = 4,
                ReviewCount = 4

            };
            App app3 = new App()
            {
                AppNo = "3",
                AppProjectId = "3",
                //ClientLogos="",
                CurrentVer = "3",
                Id = "3",
                Name = "app3",
                Price = 0.0,
                Rank = 4,
                ReviewCount = 4

            };
            App app4 = new App()
            {
                AppNo = "4",
                AppProjectId = "4",
                //ClientLogos="",
                CurrentVer = "4",
                Id = "4",
                Name = "app4",
                Price = 0.0,
                Rank = 5,
                ReviewCount = 5

            };
            App app5 = new App()
            {
                AppNo = "5",
                AppProjectId = "5",
                //ClientLogos="",
                CurrentVer = "5",
                Id = "5",
                Name = "app5",
                Price = 0.0,
                Rank = 5,
                ReviewCount = 1

            };
            App app6 = new App()
            {
                AppNo = "6",
                AppProjectId = "6",
                //ClientLogos="",
                CurrentVer = "6",
                Id = "6",
                Name = "app6",
                Price = 0.0,
                Rank = 2,
                ReviewCount = 4

            };
            #endregion
            var AppIds = new List<string>()
            {
                "1","2","3","4","5","6"
            };
            var topThreeAppIdsForT1 = new List<string>()
            {
                "1","2","3"
            };
            var topThreeAppIdsForT2 = new List<string>()
            {
                "4","5","6"
            };

            var apps = new List<App>();
            apps.Add(app1);
            apps.Add(app2);
            apps.Add(app3);

            #region Version
            var version1 = new AppVersion()
            {
                Id = "1",
                VersionName = "v1",
                FileSize = 5,
                FileUrl = "FileUrl1",
            };
            var version2 = new AppVersion()
            {
                Id = "2",
                VersionName = "v2",
                FileSize = 5,
                FileUrl = "FileUrl2",
            };
            var version3 = new AppVersion()
            {
                Id = "3",
                VersionName = "v3",
                FileSize = 5,
                FileUrl = "FileUrl3",
            };
            var version4 = new AppVersion()
            {
                Id = "4",
                VersionName = "v4",
                FileSize = 5,
                FileUrl = "FileUrl4",
            };
            var version5 = new AppVersion()
            {
                Id = "5",
                VersionName = "v5",
                FileSize = 5,
                FileUrl = "FileUrl5",
            };
            var version6 = new AppVersion()
            {
                Id = "6",
                VersionName = "v6",
                FileSize = 5,
                FileUrl = "FileUrl6",
            };

            #endregion

            #region App Project
            var appProject1 = new AppProject()
            {
                AppNo = "1",
                Id = "1",
                LogoFile = "LogoFile1",
                Name = "app project1",
                Rate = 1,
                ReviewCount = 1
            };
            var appProject2 = new AppProject()
            {
                AppNo = "2",
                Id = "2",
                LogoFile = "LogoFile2",
                Name = "app project2",
                Rate = 2,
                ReviewCount = 2
            };
            var appProject3 = new AppProject()
            {
                AppNo = "3",
                Id = "3",
                LogoFile = "LogoFile3",
                Name = "app project3",
                Rate = 3,
                ReviewCount = 3
            };
            var appProject4 = new AppProject()
            {
                AppNo = "4",
                Id = "4",
                LogoFile = "LogoFile4",
                Name = "app project4",
                Rate = 4,
                ReviewCount = 4
            };
            var appProject5 = new AppProject()
            {
                AppNo = "5",
                Id = "5",
                LogoFile = "LogoFile5",
                Name = "app project5",
                Rate = 5,
                ReviewCount = 5
            };
            var appProject6 = new AppProject()
            {
                AppNo = "6",
                Id = "6",
                LogoFile = "LogoFile6",
                Name = "app project6",
                Rate = 6,
                ReviewCount = 6
            };
            #endregion

            #endregion

            //_appStoreUIServiceMock.Setup(s => s.GetTagsByTagCategory(It.IsAny<string>())).Returns(tags);
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("1")).Returns(AppIds);
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("2")).Returns(AppIds);
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("3")).Returns(AppIds);
            _redisServiceMock2.Setup(s => s.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), It.IsAny<string>(), 1, 3, true)).Returns(topThreeAppIdsForT2);
            _redisServiceMock.Setup(s => s.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(apps);
            _redisServiceMock.Setup(s => s.GetValuesByIds<Element>(It.IsAny<List<string>>(), false)).Returns(new List<Element>());
            _redisServiceMock.Setup(s => s.Get<AppProject>("1")).Returns(appProject1);
            _redisServiceMock.Setup(s => s.Get<AppProject>("2")).Returns(appProject2);
            _redisServiceMock.Setup(s => s.Get<AppProject>("3")).Returns(appProject3);

            _redisServiceMock.Setup(s => s.GetAllSubModelIdsByType<TagCategory, TagInTagCategory>("2")).Returns(tagIds);
            _redisServiceMock2.Setup(s => s.GetSortedIdsByProperty<Tag>(tagIds, "OrderNumber", 0, 0, true)).Returns(tagIdsSortedByOrderNumber);
            _redisServiceMock.Setup(s => s.GetValuesByIds<Tag>(tagIdsSortedByOrderNumber, false)).Returns(sortedTags);

            _redisServiceMock2.Setup(s => s.GetIntersectIdsByPropertyFromSets(It.IsAny<List<string>>(), It.IsAny<List<string>>())).Returns(AppIds);
            _appStoreUIServiceMock.Setup(s => s.GetTagIdByName("Valid")).Returns("1");
            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTag("1")).Returns(AppIds);
            _redisServiceMock2.Setup(s => s.GetFilteredIdsByPropertyFromSets<App>(It.IsAny<List<string>>(), It.IsAny<string>())).Returns(AppIds);

            _appStoreUIServiceMock.Setup(s => s.GetCurrentVersionForApp("1")).Returns(version1);
            _appStoreUIServiceMock.Setup(s => s.GetCurrentVersionForApp("2")).Returns(version2);
            _appStoreUIServiceMock.Setup(s => s.GetCurrentVersionForApp("3")).Returns(version3);

            _appStoreUIServiceMock.Setup(s => s.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(topThreeAppIdsForT1);
            List<WapTagListItem> resultList = appStoresWapUIService.GetTagList(lcd,"2");

            Assert.Equal(resultList.Count, 2);
            Assert.Equal(resultList[1].TagId, "1");
            Assert.Equal(resultList[0].TagAppList.Count, 3);
            Assert.Equal(resultList[0].TagName, "娱乐");
        }
예제 #3
0
        public void AppListByTagIds_return_data_to_client_successfully()
        {
            AppProject appProj = new AppProject()
            {
                Id = "1",
                AppNo = "1",
                Name = "New App Porj"
            };
            App app1 = new App() { Id = "1", Name = "app1", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 8 };
            App app2 = new App() { Id = "2", Name = "app2", AppProjectId = "1", CurrentVer = "1", Status = 1, DownloadTimes = 10 };

            var tag1 = new Tag() { Id = "1", Name = "a" };
            var tag2 = new Tag() { Id = "2", Name = "b" };
            var tag3 = new Tag() { Id = "3", Name = "c" };
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("1")).Returns(tag3);
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("2")).Returns(tag2);
            _redisServiceMock.Setup<Tag>(m => m.Get<Tag>("3")).Returns(tag3);
            _appStoreUIServiceMock.Setup(m => m.GetAppIdsByTagNames(It.IsAny<List<string>>())).Returns(new List<string> { app1.Id, app2.Id });
            _redisServiceMock2.Setup(m => m.GetSortedIdsByProperty<App>(It.IsAny<List<string>>(), "DownloadTimes", 0, 0, true)).Returns(new List<string> { app2.Id, app1.Id });
            _redisServiceMock.Setup(m => m.GetValuesByIds<App>(It.IsAny<List<string>>(), false)).Returns(new List<App>());

            var namevalues = new NameValueCollection();
            namevalues[MobileParam.Key_Resolution] = "240x320";
            _requestRepoMock.Setup<NameValueCollection>(m => m.Header).Returns(namevalues);
            MobileParam mobileParam = new MobileParam(requestRepo);

            AppStoreService appStoreService = new AppStoreService(fileService, redisService, appStoreUIService, new FullTextSearchService(redisService), new IMEICacheService(redisService));
            int totalCount = 0;
            var result = appStoreService.GetAppListByTagIds(mobileParam, 0, 0, out totalCount, "1;2;3");
            Assert.Equal(2, totalCount);
        }
예제 #4
0
        public override ActionResult AppBranchAdd(string appProjectId)
        {
            ViewData["AppProjectName"] = Request.QueryString["appProjectName"];
            var emptyTag = new Tag { Id = "0", Name = "" };

            var topPageTags = UIService.GetTagsByTagCategory("6");
            topPageTags.Insert(0, emptyTag);
            var rankTags = UIService.GetTagsByTagCategory("5");
            rankTags.Insert(0, emptyTag);
            var businessCategoryTags = UIService.GetTagsByTagCategory("7");
            businessCategoryTags.Insert(0, emptyTag);
            var categoryTags = UIService.GetTagsByTagCategory("1").Union(UIService.GetTagsByTagCategory("2")).ToList();
            categoryTags.Insert(0, emptyTag);

            ViewData["topPageTags"] = new SelectList(topPageTags, "Id", "Name", "0");
            ViewData["rankTags"] = new SelectList(rankTags, "Id", "Name", "0");
            ViewData["businessCategoryTags"] = new SelectList(businessCategoryTags, "Id", "Name", "0");
            ViewData["categoryTags"] = new SelectList(categoryTags, "Id", "Name", "0");

            return base.AppBranchAdd(appProjectId);
        }
예제 #5
0
 public ActionResult AddTag(Tag model)
 {
     var existId = UIService.GetTagIdByName(model.Name);
     if (!string.IsNullOrEmpty(existId))
     {
         TempData["errorMsg"] = "已存在同名标签!";
     }
     var tagId = UIService.AddTag(model.Name);
     if (!string.IsNullOrEmpty(model.Type))
     {
         var tag = RedisService.Get<Tag>(tagId);
         if (tag != null)
         {
             var originalTag = CloneHelper.DeepClone<Tag>(tag);
             tag.Type = model.Type;
             tag.Color = model.Color;
             RedisService.UpdateWithRebuildIndex<Tag>(originalTag, tag);
         }
     }
     return RedirectToAction("TagManage");
 }
예제 #6
0
        public ActionResult TagEdit(Tag tag, HttpPostedFileBase logoFile)
        {
            var orginalTag = RedisService.Get<Tag>(tag.Id);
            var fileName = logoFile == null ? string.Empty : logoFile.FileName;
            if (!string.IsNullOrEmpty(fileName))
            {
                var logoPath = GetResourceFilePath("AppLogos", ResourcesFilePathHelper.AppLogoPath, string.Format("tag_logo_{0}_{1}_{2}", tag.Id, DateTime.Now.Ticks, Path.GetExtension(fileName)));
                logoFile.SaveAs(logoPath);

                tag.LogoUrl = string.Format("/AppStoreResources/AppLogos/{0}", Path.GetFileName(logoPath)).ToFileServerUrlAPP();
            }
            else
            {
                tag.LogoUrl = orginalTag.LogoUrl;
            }

            RedisService.UpdateWithRebuildIndex<Tag>(orginalTag, tag);

            return RedirectToAction("TagManage");
        }