Beispiel #1
0
        public void CanCreateContent()
        {
            IContentManagerService cs = CreateContentManagerService();

            string title = "Title Separated Let's try";

            Content c = cs.Create(title, "Test content body", "key words test", "Promotional Text", new ContentCategory(1), 1, CreateContentFashionFlavors(), CreateSections());

            Assert.IsTrue(c.Title == title);
            Assert.IsTrue(c.UserFriendlyTitle == "/Content/Blog/title-separated-let-s-try/0/default.aspx", c.UserFriendlyTitle);
            Assert.IsTrue(c.Status == ContentStatus.Draft);
            Assert.IsTrue(c.Flavors.Count == 4);
            Assert.IsTrue(c.Sections.Count == 4);
        }
        private void SaveData(ContentView content, int[] flavors)
        {
            IList <FashionFlavor> lstFlavors = new List <FashionFlavor>();

            if (flavors != null)
            {
                for (int i = 0; i < flavors.Length; i++)
                {
                    lstFlavors.Add(fashionFlavorRepository.Get(flavors[i]));
                }
            }

            IList <ContentSection> lstSections = new List <ContentSection>();

            foreach (ContentViewSection cs in content.Sections)
            {
                lstSections.Add(new ContentSection {
                    Body = cs.Body, Title = cs.Title, FashionFlavor = cs.FashionFlavor
                });
            }

            if (content.Id == 0)
            {
                contentManagerService.Create(content.Title, content.Body, content.Keywords, content.PromotionalText, new ContentCategory(content.Category.Value), Convert.ToInt32(Membership.GetUser().ProviderUserKey), lstFlavors, lstSections);
            }
            else
            {
                contentManagerService.Edit(content.Id, content.Title, content.Body, content.Keywords, content.PromotionalText, new ContentCategory(content.Category.Value), (ContentType)content.Type, lstFlavors, lstSections);

                // If a editor/author wants to edit a publish content, it should be Send To Verify.
                if (content.Status == ContentStatus.Published && RolePermissionService.CanCreate())
                {
                    contentManagerService.SendToVerify(content.Id, Convert.ToInt32(Membership.GetUser().ProviderUserKey));
                }
            }
        }