public void ShouldReturnSecondCategoryImageUrlIfFirstCategoryImageUrlIsEmptyButSecondCategoryImageUrlIsNot()
        {
            // Arrange
            var groupCategoryWithOutImageUrl = new GroupCategory()
            {
                Icon     = "icon",
                ImageUrl = "",
                Name     = "name",
                Slug     = "slug"
            };
            var groupCategoryWithImageUrl = new GroupCategory()
            {
                Icon     = "icon",
                ImageUrl = "categoryImageUrl",
                Name     = "name",
                Slug     = "slug"
            };

            var groupWithImage = new GroupBuilder().Image(string.Empty).Categories(new List <GroupCategory> {
                { groupCategoryWithOutImageUrl }, { groupCategoryWithImageUrl }
            }).Build();

            // Act
            var outputImageUrl = GroupImageUrlHelper.GetImageUrl(groupWithImage);

            // Assert
            outputImageUrl.Should().Be("categoryImageUrl");
        }
Example #2
0
        public virtual void GroupAdmin(long id)
        {
            set("SearchAction", to(GroupAdmin, -1));
            set("categoryLink", to(GroupAdmin, 999));

            int typeId = getTypeId();
            DataPage <Group> groups = getGroups(id, typeId);

            bindGroups(groups.Results);
            set("page", groups.PageBar);

            GroupCategory c            = db.findById <GroupCategory>(id);
            String        categoryName = (c == null ? "" : c.Name);

            set("categoryName", categoryName);

            List <GroupCategory> categories = new List <GroupCategory>();

            categories.Add(new GroupCategory(0, 0, lang("all")));
            foreach (GroupCategory gc in GroupCategory.GetAll())
            {
                categories.Add(gc);
            }

            bindGroupFilter(id, categories);
        }
        public async Task <IActionResult> Edit(int id, [Bind("Name,Id")] GroupCategory groupCategory)
        {
            if (id != groupCategory.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try {
                    _context.Update(groupCategory);
                    await _context.SaveChangesAsync();
                } catch (DbUpdateConcurrencyException) {
                    if (!GroupCategoryExists(groupCategory.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(groupCategory));
        }
Example #4
0
        public void ShouldReturnAListOfAListOfCategories()
        {
            // Arrange
            const string slug                   = "unit-test-GroupCategory";
            var          testCategorySlug       = "test-category-slug";
            var          listOfContentfulGroups = SetupMockFactoriesAndGetContentfulGroupsForCollection(testCategorySlug);
            var          collection             = new ContentfulCollection <ContentfulGroup>();

            collection.Items = listOfContentfulGroups;

            var rawContentfulGroupCategory = new ContentfulGroupCategoryBuilder().Slug(slug).Build();
            var rawGroupCategory           = new GroupCategory("name", slug, "icon", "imageUrl");

            var builder = new QueryBuilder <ContentfulGroup>().ContentTypeIs("group").Include(1).FieldEquals("fields.mapPosition[near]", Defaults.Groups.StockportLatitude + "," + Defaults.Groups.StockportLongitude + ",10").Build();

            _client.Setup(o => o.GetEntries <ContentfulGroup>(It.Is <string>(q => q.Contains(builder)),
                                                              It.IsAny <CancellationToken>())).ReturnsAsync(collection);
            _cacheWrapper.Setup(o => o.GetFromCacheOrDirectlyAsync(It.Is <string>(s => s == "group-categories"), It.IsAny <Func <Task <List <GroupCategory> > > >(), It.Is <int>(s => s == 60))).ReturnsAsync(new List <GroupCategory>()
            {
                rawGroupCategory
            });

            var noLatLngBuilder = new QueryBuilder <ContentfulGroup>().ContentTypeIs("group").Include(1).Build();

            _client.Setup(o => o.GetEntries <ContentfulGroup>(It.Is <string>(q => q.Contains(noLatLngBuilder)),
                                                              It.IsAny <CancellationToken>())).ReturnsAsync(collection);

            // Act
            var response             = AsyncTestHelper.Resolve(_repository.GetGroupResults(new GroupSearch(), slug));
            var filteredGroupResults = response.Get <GroupResults>();

            // Assert
            response.StatusCode.Should().Be(HttpStatusCode.OK);
            filteredGroupResults.Categories.Count.Should().Be(1);
        }
Example #5
0
        public override void Layout()
        {
            // 当前app/module所有页面,所属的首页
            ctx.SetItem("_moduleUrl", to(Index));

            List <GroupCategory> categories = GroupCategory.GetAll();
            IBlock block = getBlock("categories");

            foreach (GroupCategory c in categories)
            {
                block.Set("c.Name", c.Name);
                block.Set("c.Link", to(List, c.Id));
                block.Next();
            }

            String name = ctx.Get("name");

            set("s.Name", name);

            set("SearchAction", to(Search));

            set("allGroupLink", to(List, -1));

            bindAdminLink();
        }
Example #6
0
        private List <ContentfulGroup> SetupMockFactoriesAndGetContentfulGroupsForCollection(string testCategorySlug)
        {
            var contentfulGroupCategory     = new ContentfulGroupCategoryBuilder().Slug(testCategorySlug).Build();
            var contentfulGroupWithCategory = new ContentfulGroupBuilder().Slug("slug-with-categories").CategoriesReference(
                new List <ContentfulGroupCategory> {
                contentfulGroupCategory
            }).Build();
            var contentfulGroupWithoutCategory = new ContentfulGroupBuilder().Slug("slug-without-categories").Build();

            var groupCategory     = new GroupCategory("name", testCategorySlug, "icon", "imagueUrl");
            var groupWithCategory = new GroupBuilder().Slug("slug-with-categories").CategoriesReference(
                new List <GroupCategory>()
            {
                groupCategory
            })
                                    .Build();

            var groupWithoutCategory = new GroupBuilder().Slug("slug-without-categories").Build();

            _groupFactory.Setup(o => o.ToModel(contentfulGroupWithCategory)).Returns(groupWithCategory);
            _groupFactory.Setup(o => o.ToModel(contentfulGroupWithoutCategory)).Returns(groupWithoutCategory);

            return(new List <ContentfulGroup>
            {
                contentfulGroupWithCategory,
                contentfulGroupWithoutCategory
            });
        }
Example #7
0
        public HttpResponseMessage NewGroupCategory(HttpRequestMessage request)
        {
            GroupCategory          groupCategory = new GroupCategory();
            GroupCategoryViewModel model         = new GroupCategoryViewModel(groupCategory);

            return(request.CreateResponse <GroupCategoryViewModel>(HttpStatusCode.OK, model));
        }
        public GroupCategory ToEntity(GroupCategory existing = null)
        {
            GroupCategory entity = (existing != null ? existing : new GroupCategory());

            entity.Id   = this.Id;
            entity.Name = this.Name;

            return(entity);
        }
Example #9
0
        public void SetPartyType(GroupCategory category, GroupType type)
        {
            Cypher.Assert(category < GroupCategory.Max);
            byte value = GetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType);

            value &= (byte)~((byte)0xFF << ((byte)category * 4));
            value |= (byte)((byte)type << ((byte)category * 4));
            SetByteValue(PlayerFields.Bytes3, PlayerFieldOffsets.Bytes3OffsetPartyType, value);
        }
Example #10
0
        public void Create(CreateGroupCategoryDto dto)
        {
            var groupCategory = new GroupCategory
            {
                Title = dto.Title
            };

            _groupCategoryRepository.Insert(groupCategory);
        }
Example #11
0
        public void SetPartyType(GroupCategory category, GroupType type)
        {
            Cypher.Assert(category < GroupCategory.Max);
            byte value = m_playerData.PartyType;

            value &= (byte)~((byte)0xFF << ((byte)category * 4));
            value |= (byte)((byte)type << ((byte)category * 4));
            SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.PartyType), value);
        }
        public GroupCategoryViewModel(GroupCategory entity, bool useCategories = true)
        {
            Id   = entity.Id;
            Name = entity.Name;

            if (useCategories)
            {
                Categories = entity.Categories.Select(c => new CategoryViewModel(c)).ToList();
            }
        }
        public void GroupsBrowseBasicTest()
        {
            GroupCategory cat = AuthInstance.GroupsBrowse();

            Assert.IsNotNull(cat, "GroupCategory should not be null.");
            Assert.AreEqual("/", cat.CategoryName, "CategoryName should be '/'.");
            Assert.AreEqual("/", cat.Path, "Path should be '/'.");
            Assert.AreEqual("", cat.PathIds, "PathIds should be empty string.");
            Assert.AreEqual(0, cat.Subcategories.Count, "No sub categories should be returned.");
            Assert.AreEqual(0, cat.Groups.Count, "No groups should be returned.");
        }
        public async Task <IActionResult> Create([Bind("Name,Id")] GroupCategory groupCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(groupCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(groupCategory));
        }
Example #15
0
        public ActionResult AddOrEditGroupCategory(int id = 0)
        {
            SetViewBag();
            var typeProduct = new GroupCategory();

            if (id != 0)
            {
                typeProduct = danhMucDAO.GetGroupCategoryByID(id);
            }
            return(View(typeProduct));
        }
Example #16
0
        public void ResetGroupUpdateSequenceIfNeeded(Group group)
        {
            GroupCategory category = group.GetGroupCategory();

            // Rejoining the last group should not reset the sequence
            if (m_groupUpdateSequences[(int)category].GroupGuid != group.GetGUID())
            {
                var groupUpdate = m_groupUpdateSequences[(int)category];
                groupUpdate.GroupGuid            = group.GetGUID();
                groupUpdate.UpdateSequenceNumber = 1;
            }
        }
Example #17
0
        public HttpResponseMessage GetGroupCategory(HttpRequestMessage request, int groupCategoryId)
        {
            GroupCategory groupCategory = _service.GetGroupCategory(groupCategoryId);

            if (groupCategory != null)
            {
                GroupCategoryViewModel model = new GroupCategoryViewModel(groupCategory);
                return(request.CreateResponse <GroupCategoryViewModel>(HttpStatusCode.OK, model));
            }

            return(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
        public bool InsertGroupCategory(GroupCategory groupCategory)
        {
            try
            {
                _unitOfWork.GroupCategoriesRepository.Insert(groupCategory);
                _unitOfWork.Save();
                return(true);
            }
            catch { }

            return(false);
        }
Example #19
0
 public bool AddGroupCategory(GroupCategory type)
 {
     try
     {
         data.GroupCategories.Add(type);
         data.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Example #20
0
        [ValidateModel] //this will handle validation (and return with errors) before method is run
        public HttpResponseMessage InsertGroupCategory(HttpRequestMessage request, [FromBody] GroupCategoryViewModel groupCategory)
        {
            GroupCategory entity = groupCategory.ToEntity();

            //save it
            if (_service.InsertGroupCategory(entity))
            {
                GroupCategoryViewModel model = new GroupCategoryViewModel(entity);
                return(request.CreateResponse <GroupCategoryViewModel>(HttpStatusCode.OK, model));
            }

            return(new HttpResponseMessage(HttpStatusCode.BadRequest));
        }
Example #21
0
        public HttpResponseMessage DeleteGroupCategory(HttpRequestMessage request, int groupCategoryId)
        {
            GroupCategory groupCategory = _service.GetGroupCategory(groupCategoryId);

            if (groupCategory != null)
            {
                if (_service.DeleteGroupCategory(groupCategory))
                {
                    return(new HttpResponseMessage(HttpStatusCode.OK));
                }

                return(new HttpResponseMessage(HttpStatusCode.InternalServerError));
            }
            return(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
Example #22
0
 public bool EditGroupCategory(GroupCategory Newtype)
 {
     try
     {
         var old = data.GroupCategories.SingleOrDefault(q => q.ID == Newtype.ID);
         old.NAME   = Newtype.NAME;
         old.IDType = Newtype.IDType;
         data.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        //---------------------------------------------------------------------


        public void New()
        {
            target(StepTwo);

            set("siteUrl", strUtil.TrimEnd(ctx.url.SiteAndAppPath, "/"));
            set("urlExt", MvcConfig.Instance.UrlExt);
            set("groupPath", MemberPath.GetPath(typeof(Group).Name));

            int categoryId = (ctx.PostInt("Category") > 0) ? ctx.PostInt("Category") : 1;

            dropList("Category", GroupCategory.GetAll(), "Name=Id", categoryId);

            setAccessStatus();

            set("isNameValidLink", to(CheckNameExist));
            set("isUrlValidLink", to(CheckUrlExist));
        }
 public ProcessedGroupHomepage(string title, string metaDescription, string backgroundImage, string featuredGroupsHeading, List <Group> featuredGroups,
                               GroupCategory featuredGroupsCategory, GroupSubCategory featuredGroupsSubCategory, List <Alert> alerts, string bodyHeading, string body, string secondaryBodyHeading, string secondaryBody, EventBanner eventBanner)
 {
     Title                     = title;
     MetaDescription           = metaDescription;
     BackgroundImage           = backgroundImage;
     FeaturedGroupsHeading     = featuredGroupsHeading;
     FeaturedGroups            = featuredGroups;
     FeaturedGroupsCategory    = featuredGroupsCategory;
     FeaturedGroupsSubCategory = featuredGroupsSubCategory;
     Alerts                    = alerts;
     BodyHeading               = bodyHeading;
     Body = body;
     SecondaryBodyHeading = secondaryBodyHeading;
     SecondaryBody        = secondaryBody;
     EventBanner          = eventBanner;
 }
Example #25
0
        public ActionResult AddOrEditGroupCategory(GroupCategory type)
        {
            bool   result = false;
            string status = "Lưu Thất Bại!";

            if (type.ID == 0)
            {
                result = danhMucDAO.AddGroupCategory(type);
                status = "Lưu Thành Công!";
            }
            else
            {
                result = danhMucDAO.EditGroupCategory(type);
                status = "Lưu Thành Công!";
            }
            return(Json(new { Result = result, message = status }, JsonRequestBehavior.AllowGet));
        }
Example #26
0
        public HttpResponseMessage NewCategory(HttpRequestMessage request, int groupCategoryId)
        {
            GroupCategory groupCategory = _service.GetGroupCategory(groupCategoryId);

            if (groupCategory != null)
            {
                Category category = new Category()
                {
                    GroupCategory = groupCategory
                };
                List <OrganisationalUnit>   allOrganisationalUnits = _service.GetWebServiceOrganisationalUnits();
                List <PropertyQueryGroup>   allPropertyQueryGroups = _service.GetWebServicePropertyQueries();
                CategoryWithUnusedViewModel model = new CategoryWithUnusedViewModel(category, allOrganisationalUnits, allPropertyQueryGroups);
                return(request.CreateResponse <CategoryWithUnusedViewModel>(HttpStatusCode.OK, model));
            }

            return(new HttpResponseMessage(HttpStatusCode.NotFound));
        }
Example #27
0
        private void bindGroupInfo(Group group)
        {
            set("g.Name", group.Name);
            set("g.Description", group.Description);
            set("g.Url", group.Url);

            set("siteUrl", strUtil.TrimEnd(ctx.url.SiteAndAppPath, "/"));
            set("cfg.UrlExt", MvcConfig.Instance.UrlExt);
            set("groupPath", MemberPath.GetPath(typeof(Group).Name));

            int categoryId = (ctx.PostInt("Category") > 0) ? ctx.PostInt("Category") : group.Category.Id;

            dropList("Category", GroupCategory.GetAll(), "Name=Id", categoryId);
            this.setAccessStatus();

            String chk = group.IsCloseJoinCmd == 1 ? "checked=\"checked\"" : "";

            set("g.IsCloseJoinCmd", chk);
        }
Example #28
0
        public override void Layout()
        {
            List <GroupCategory> categories = GroupCategory.GetAll();
            IBlock block = getBlock("categories");

            foreach (GroupCategory c in categories)
            {
                block.Set("c.Name", c.Name);
                block.Set("c.Link", to(List, c.Id));
                block.Next();
            }

            String name = ctx.Get("name");

            set("s.Name", name);

            set("SearchAction", to(Search));

            set("allGroupLink", to(List, -1));
        }
        public void ShouldReturnGroupHomepage()
        {
            // Arrange
            var eventBanner   = new EventBanner("title", "teaser", "icon", "link");
            var featuredGroup = new GroupBuilder().Build();
            var category      = new GroupCategory("title", "slug", "icon", "image");
            var subCategory   = new GroupSubCategory("title", "slug");
            var alert         = new Alert("title", "subheading", "body", "severity", DateTime.MinValue, DateTime.MinValue,
                                          "slug", false);

            _groupFactory.Setup(o => o.ToModel(It.IsAny <ContentfulGroup>())).Returns(featuredGroup);
            _groupCategoryFactory.Setup(o => o.ToModel(It.IsAny <ContentfulGroupCategory>())).Returns(category);
            _groupSubCategoryFactory.Setup(o => o.ToModel(It.IsAny <ContentfulGroupSubCategory>())).Returns(subCategory);
            _eventBannerFactory.Setup(o => o.ToModel(_contentfulGroupHomepage.EventBanner)).Returns(eventBanner);
            _alertFactory.Setup(_ => _.ToModel(It.IsAny <ContentfulAlert>())).Returns(alert);

            // Act
            var result = _groupHomepageContentfulFactory.ToModel(_contentfulGroupHomepage);

            // Assert
            result.Title.Should().Be("title");
            result.Slug.Should().Be("slug");
            result.MetaDescription.Should().Be("metaDescription");
            result.BackgroundImage.Should().Be("image-url.jpg");
            result.FeaturedGroupsHeading.Should().Be("heading");

            result.FeaturedGroups.Count.Should().Be(1);
            result.FeaturedGroups.First().Should().BeEquivalentTo(featuredGroup);

            result.FeaturedGroupsCategory.Should().BeEquivalentTo(category);
            result.FeaturedGroupsSubCategory.Should().BeEquivalentTo(subCategory);

            result.Alerts.Count().Should().Be(1);
            result.Alerts.First().Should().BeEquivalentTo(alert);

            result.BodyHeading.Should().Be("bodyheading");
            result.Body.Should().Be("body");
            result.SecondaryBodyHeading.Should().Be("secondaryBodyHeading");
            result.SecondaryBody.Should().Be("secondaryBody");
            result.EventBanner.Should().BeEquivalentTo(eventBanner);
        }
Example #30
0
        public void List(int id)
        {
            ctx.Page.Title = "群组列表";

            GroupCategory category = db.findById <GroupCategory>(id);

            if (category != null)
            {
                String groupsByCategory = string.Format(lang("groupsByCategory"), category.Name);
                set("groupsByCategory", groupsByCategory);
            }
            else
            {
                set("groupsByCategory", lang("all"));
            }

            DataPage <Group> groups = groupService.GetByCategory(id);

            bindGroups(groups.Results, "list");
            set("page", groups.PageBar);
        }