Ejemplo n.º 1
0
        public void CanEditContent()
        {
            IContentManagerService cs = CreateContentManagerService();

            string title = "Title edited";
            string body  = "body edited";

            Content c = cs.Edit(1, title, body, "key words test", "Promotional Text", new ContentCategory(1), ContentType.Blog, CreateContentFashionFlavors(), CreateSections());

            Assert.IsTrue(c.Title == title);
            Assert.IsTrue(c.UserFriendlyTitle == "/Content/Blog/title-edited/1/default.aspx");
            Assert.IsTrue(c.Status == ContentStatus.Draft);
            Assert.IsTrue(c.Flavors.Count == 4);
            Assert.IsTrue(c.Sections.Count == 4);
        }
Ejemplo n.º 2
0
        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));
                }
            }
        }