public async Task <object> CreateDesignRequest([FromBody] RequestDesignDTO dto)
        {
            var req           = Request.Files;
            var designRequest = _contentService.Create(dto.Email, 1456, "designRequest");

            designRequest.SetValue("email", dto.Email);
            designRequest.SetValue("phone", dto.Phone);
            designRequest.SetValue("size", dto.Size);
            designRequest.SetValue("product", dto.Product);
            designRequest.SetValue("stilart", dto.Style);
            designRequest.SetValue("stilTekst", dto.Text);
            designRequest.SetValue("kommentar", dto.Comments);
            _contentService.SaveAndPublish(designRequest);
            int i = 1;

            foreach (var key in req.AllKeys)
            {
                var imageContent = _contentService.Create("image-" + i, designRequest.Id, "designRequestImage");
                var fileName     = req[key].FileName;
                imageContent.SetValue("type", key);
                imageContent.SetValue(Services.ContentTypeBaseServices, "image", fileName, req[key].InputStream);

                _contentService.SaveAndPublish(imageContent);
                i++;
            }

            return(new { complete = true });
        }
Esempio n. 2
0
        public int CreateErrorNode(string documentTypeAlias, string nodeName, IDomainService domainService)
        {
            var docType   = contentTypeService.Get(documentTypeAlias);
            var languages = domainService.GetAll(false);

            try
            {
                IContent node = contentService.Create(nodeName, -1, documentTypeAlias);
                node.Name = nodeName;
                foreach (var language in languages)
                {
                    node.SetCultureName(nodeName, language.LanguageIsoCode);
                }

                contentService.Save(node);

                ConnectorContext.AuditService.Add(AuditType.New, -1, node.Id, "Error Content Node", $"Generic Error Node {nodeName} has been created");
                return(node.Id);
            }
            catch (Exception ex)
            {
                logger.Error(typeof(NodeHelper), ex.Message);
                logger.Error(typeof(NodeHelper), ex.StackTrace);
                throw;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Creates and initializes a new page of the specified type.
 /// </summary>
 /// <returns>The created page</returns>
 public T Create <T>(string typeId = null) where T : Models.PageBase
 {
     if (string.IsNullOrWhiteSpace(typeId))
     {
         typeId = typeof(T).Name;
     }
     return(_contentService.Create <T>(_api.PageTypes.GetById(typeId)));
 }
Esempio n. 4
0
        public ActionResult CreateContent(ContentViewModel content)
        {
            var bllContent = content.ToBllContent();

            bllContent.UserId = _userService.GetUserEntity(User.Identity.Name).Id;
            _contentService.Create(bllContent);
            return(RedirectToAction("Index"));
        }
Esempio n. 5
0
        /// <summary>
        /// When a new root Articulate node is created, then create the required 2 sub nodes
        /// </summary>
        private void ContentService_Saved(IContentService contentService, SaveEventArgs <IContent> e)
        {
            foreach (var c in e.SavedEntities)
            {
                if (!c.WasPropertyDirty("Id") || !c.ContentType.Alias.InvariantEquals(ArticulateContentTypeAlias))
                {
                    continue;
                }

                //it's a root blog node, set up the required sub nodes (archive , authors) if they don't exist

                var defaultLang = _languageService.GetDefaultLanguageIsoCode();

                var children = contentService.GetPagedChildren(c.Id, 0, 10, out var total).ToList();
                if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateArchive"))
                {
                    var archiveContentType = _contentTypeService.Get("ArticulateArchive");
                    if (archiveContentType != null)
                    {
                        if (archiveContentType.VariesByCulture())
                        {
                            var articles = contentService.Create("", c, "ArticulateArchive");
                            articles.SetCultureName("Archive", defaultLang);
                            contentService.Save(articles);
                        }
                        else
                        {
                            var articles = contentService.CreateAndSave("Archive", c, "ArticulateArchive");
                        }
                    }
                }

                if (total == 0 || children.All(x => x.ContentType.Alias != "ArticulateAuthors"))
                {
                    var authorContentType = _contentTypeService.Get("ArticulateAuthors");
                    if (authorContentType != null)
                    {
                        if (authorContentType.VariesByCulture())
                        {
                            var authors = contentService.Create("", c, "ArticulateAuthors");
                            authors.SetCultureName("Authors", defaultLang);
                            contentService.Save(authors);
                        }
                        else
                        {
                            var authors = contentService.CreateAndSave("Authors", c, "ArticulateAuthors");
                        }
                    }
                }
            }
        }
        public IActionResult Install()
        {
            var contentType = new ContentType(_shortStringHelper, -1)
            {
                Alias       = ContentAlias,
                Name        = "LoadTest Content",
                Description = "Content for LoadTest",
                Icon        = "icon-document"
            };
            IDataType def = _dataTypeService.GetDataType(TextboxDefinitionId);

            contentType.AddPropertyType(new PropertyType(_shortStringHelper, def)
            {
                Name        = "Origin",
                Alias       = "origin",
                Description = "The origin of the content.",
            });
            _contentTypeService.Save(contentType);

            Template containerTemplate = ImportTemplate(
                "LoadTestContainer",
                "LoadTestContainer",
                s_containerTemplateText);

            var containerType = new ContentType(_shortStringHelper, -1)
            {
                Alias         = ContainerAlias,
                Name          = "LoadTest Container",
                Description   = "Container for LoadTest content",
                Icon          = "icon-document",
                AllowedAsRoot = true,
                IsContainer   = true
            };

            containerType.AllowedContentTypes = containerType.AllowedContentTypes.Union(new[]
            {
                new ContentTypeSort(new Lazy <int>(() => contentType.Id), 0, contentType.Alias),
            });
            containerType.AllowedTemplates = containerType.AllowedTemplates.Union(new[] { containerTemplate });
            containerType.SetDefaultTemplate(containerTemplate);
            _contentTypeService.Save(containerType);

            IContent content = _contentService.Create("LoadTestContainer", -1, ContainerAlias);

            _contentService.SaveAndPublish(content);

            return(ContentHtml("Installed."));
        }
Esempio n. 7
0
        private void SavePlaylistItems(IList <PlaylistItem> playlistContentItems, string playlist,
                                       IContentService contentService)
        {
            var playlistContentInformation = GetPlaylistContentInformation(playlist);

            if (playlistContentInformation.PlaylistId <= default(int))
            {
                return;
            }

            foreach (var currentPlaylistItem in playlistContentInformation.PlaylistItemsContent)
            {
                var currentPlaylistItemContent = contentService.GetById(currentPlaylistItem.Id);
                contentService.Delete(currentPlaylistItemContent);
            }

            foreach (var playlistContentItem in playlistContentItems)
            {
                var content = contentService.Create(playlistContentItem.PlaylistItemTitle,
                                                    playlistContentInformation.PlaylistId,
                                                    DocumentTypes.PlaylistItem);
                content.SetValue(PropertyAliases.PlaylistItem.PlaylistItemTitle,
                                 playlistContentItem.PlaylistItemTitle);
                content.SetValue(PropertyAliases.PlaylistItem.PlaylistItemThumbnailUrl,
                                 playlistContentItem.PlaylistItemThumbnailUrl);
                content.SetValue(PropertyAliases.PlaylistItem.PlaylistItemVideoUrl,
                                 playlistContentItem.PlaylistItemVideoUrl);
                content.SetValue(PropertyAliases.PlaylistItem.PlaylistUploadDate,
                                 playlistContentItem.PlaylistUploadDate);
                contentService.SaveAndPublish(content);
            }
        }
Esempio n. 8
0
        protected override IContent CreateItem(string alias, ITreeEntity parent, string itemType)
        {
            var parentId = parent != null ? parent.Id : -1;
            var item     = contentService.Create(alias, parentId, itemType);

            return(item);
        }
Esempio n. 9
0
        /// <summary>
        /// 新增節點
        /// </summary>
        /// <param name="pid">父節點</param>
        /// <param name="childContentTypeAlias">子節點代名</param>
        /// <param name="childNodeName">子節點名稱</param>
        /// <returns>節點</returns>
        public IContent CreateNewNode(int pid, string childContentTypeAlias, string childNodeName = null)
        {
            IContent node = _service.Create(childNodeName ?? childContentTypeAlias, pid, childContentTypeAlias);

            _service.SaveAndPublish(node);
            return(node);
        }
Esempio n. 10
0
        public Product Create(ProductCreate model)
        {
            if (model == null)
            {
                throw new BadRequestException($"{nameof(ProductCreate)} model cannot be empty");
            }

            var productRoot = GetProductRootPage();

            if (productRoot == null)
            {
                throw new EntityNotFoundException(typeof(ProductContentType));
            }

            var product = _contentService.Create(model.Name, productRoot.Id, ProductContentType.ModelTypeAlias);

            product.SetValue(nameof(ProductContentType.Description), model.Description);

            var result = _contentService.SaveAndPublish(product);

            if (!result.Success)
            {
                throw new BadRequestException("Failed creating new product");
            }

            return(GetById(product.Id));
        }
Esempio n. 11
0
        private void CreateTour()
        {
            int               userId   = 0;
            IContentService   cs       = Services.ContentService;
            IPublishedContent home     = Umbraco.AssignedContentItem.AncestorOrSelf("home");
            var               homePage = CurrentPage.AncestorOrSelf("home");
            //var MyContent = Umbraco.Content(1111).Url();
            var umbesEntityService = Services.EntityService;
            var sdsd = umbesEntityService.GetKey(homePage.Id, UmbracoObjectTypes.Document);
            var id   = "umb://document/" + sdsd;
            //Udi udi = Udi.Parse(id) ;

            //if (Udi.TryParse(id, out udi))
            //{
            //    return udi.ToPublishedContent();
            //}

            //IPublishedContent gContent = umbracoHelper.TypedContent(1111);
            var gid = new Guid("0b949542-2625-4a11-9516-5c6446b26eca");
            //var content = cs.Create("Tour2", new Guid(sdsd.ToString()), "Tour", userId);
            var content = cs.Create("Tour3", gid, "Tour", userId);

            // Umbraco.
            //content.SetValue("Name", "Test121");
            content.SetValue("HeroTitle", "Test121");
            content.SetValue("HeroDescription", "Hike one of the most beautiful mountain landscapes in the world. Italy’s dramatic rocky rooftop, the Dolomites offer spectacular views and lovely surroundings, especially on this spring tour. You will enjoy the wild Alpine meadows, snow-tipped peaks and cobblestone mountain villages. We will take scenic paths from Cortina d’ Ampezzo to Alta Badia and learn about the fascinating history of the region along the way.");
            cs.SaveAndPublish(content, "*", -1, true);
        }
Esempio n. 12
0
        public ActionResult Update(SubCategoryViewModel viewModel)
        {
            var user = new AppUser
            {
                Id    = User.Identity.GetUserId <int>(),
                Email = User.Identity.Name
            };
            var category = new Category {
                Id = viewModel.CategoryId
            };
            var subCategory = new SubCategory
            {
                Name        = viewModel.Name,
                Description = viewModel.Description,
                Id          = viewModel.Id,
                Category    = category
            };

            if (subCategory.Id == 0)
            {
                subCategoryService.Create(user, subCategory);
            }
            else
            {
                subCategoryService.Update(user, subCategory);
            }
            return(RedirectToAction("Index", "Category"));
        }
Esempio n. 13
0
        public async Task <IActionResult> Create(Content content)
        {
            if (content.ContentTypeId == 0)
            {
                throw new Exception("نوع محتوا مشخص نیست ");
            }
            if (ModelState.IsValid)
            {
                if (content.Id == 0)
                {
                    await _contentService.Create(content);

                    Success("محتوا با موفقیت افزوده شد ", true);
                }
                else
                {
                    var baseContent = await _contentService.GetAll().AsNoTracking().FirstOrDefaultAsync(c => c.Id == content.Id);

                    baseContent.Keywords       = content.Keywords;
                    baseContent.Name           = content.Name;
                    baseContent.ContentTypeId  = content.ContentTypeId;
                    baseContent.CoverImageId   = content.CoverImageId;
                    baseContent.ProfileImageId = content.ProfileImageId;
                    baseContent.Description    = content.Description;
                    baseContent.Title          = content.Description;
                    baseContent.Text           = content.Text;

                    await _contentService.Update(baseContent);

                    Success("محتوا با موفقیت ویرایش شد ", true);
                }
                return(RedirectToAction("Index", "Content"));
            }
            return(View(content));
        }
Esempio n. 14
0
        public async Task <bool> DownMusic(string link, string Title = null, string SubTitle = null, string src = null)
        {
            try
            {
                //download file
                var main   = new Main();
                var net    = new System.Net.WebClient();
                var adress = _hostingEnvironment.WebRootPath + "/content/files/" + Title + "/music";
                if (!Directory.Exists(adress))
                {
                    Directory.CreateDirectory(adress);
                }
                net.DownloadFile(link, adress + @"\" + SubTitle + ".mp3");
                net.DownloadFile(src, adress + @"\" + SubTitle + ".jpg");

                //save to content entity
                Title    = Title.Replace("-", " ");
                SubTitle = SubTitle.Replace("-", " ");
                var content = new MusicProject.Entities.Content.Content()
                {
                    Title    = Title,
                    SubTitle = SubTitle,
                    Mp3320   = "/content/files/" + Title + "/music/" + SubTitle + ".mp3",
                    Pic      = "/content/files/" + Title + "/music/" + SubTitle + ".jpg",
                    TypeId   = 10
                };
                _contentService.Create(content);
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
Esempio n. 15
0
        public bool Post(ContentModel model)
        {
            var entity = new ContentEntity
            {
                Content = model.Content,

                Title = model.Title,

                Adduser = model.Adduser,

                Addtime = model.Addtime,

                Upduser = model.Upduser,

                Updtime = model.Updtime,

                Status = model.Status,

                Praise = model.Praise,

                Unpraise = model.Unpraise,

                Viewcount = model.Viewcount,

//				Tags = model.Tags,

//				Channels = model.Channels,
            };

            if (_ContentService.Create(entity).Id > 0)
            {
                return(true);
            }
            return(false);
        }
        string IMetaWeblog.AddPost(string blogid, string username, string password, MetaWeblogPost post, bool publish)
        {
            var user = ValidateUser(username, password);

            var root = BlogRoot();

            var node = root.ChildrenOfType("ArticulateArchive").FirstOrDefault();

            if (node == null)
            {
                throw new XmlRpcFaultException(0, "No Articulate Archive node found");
            }

            var content = _contentService.Create(
                post.Title, node.Id, "ArticulateRichText", user.Id);

            var extractFirstImageAsProperty = false;

            if (root.HasProperty("extractFirstImage"))
            {
                extractFirstImageAsProperty = root.Value <bool>("extractFirstImage");
            }

            AddOrUpdateContent(content, post, user, publish, extractFirstImageAsProperty);

            return(content.Id.ToString(CultureInfo.InvariantCulture));
        }
Esempio n. 17
0
        public string Update(TopicViewModel topic)
        {
            var user = new AppUser
            {
                Id = User.Identity.GetUserId <int>()
            };
            var subcategory = new SubCategory
            {
                Id = topic.SubCategoryId
            };
            var t = new Topic
            {
                Id          = topic.Id,
                Message     = topic.Message,
                Description = topic.Description,
                User        = user,
                SubCategory = subcategory
            };

            if (topic.Id == 0)
            {
                topicService.Create(user, t);
            }
            else
            {
                topicService.Update(user, t);
            }
            return(Url.Action("Index", new { Id = t.Id }));
        }
        private IContent CreateDateFolder(IContent parentNode, string name)
        {
            IContent dateFolder = contentService.Create(name, parentNode.Id, "DateFolder");

            contentService.SaveAndPublish(dateFolder);

            return(dateFolder);
        }
        private void CreateCheckoutStepPage(IContent parent, string name, string shortName, string stepType)
        {
            var checkoutStepNode = _contentService.Create(name, parent.Id,
                                                          VendrCheckoutConstants.ContentTypes.Aliases.CheckoutStepPage);

            checkoutStepNode.SetValue("vendrShortStepName", shortName);
            checkoutStepNode.SetValue("vendrStepType", $"[\"{stepType}\"]");

            _contentService.Save(checkoutStepNode);
        }
        public int CreateTenant(Tenant tenant)
        {
            var nodeName  = tenant.Name;
            var nodeAlias = tenant.Name.Trim(' ').ToLower();
            //var nodeName = tenant.BrandName;
            //var nodeAlias = tenant.BrandName.Trim(' ').ToLower();
            var docType = contentTypeService.Get(Phase2MergedHomeDocumentType.DOCUMENT_TYPE_ALIAS);

            tenant.TenantPreferences.PaymentSettings = tenant.PaymentSettings; //little hack to match total coding system submission to umbraco properties
            tenant.PaymentSettings = null;
            Validate(tenant);
            try
            {
                IContent tenantNode = contentService.Create(nodeName, -1, Phase2MergedHomeDocumentType.DOCUMENT_TYPE_ALIAS);
                tenantNode.Name = nodeName;
                tenantNode.SetCultureName(nodeName, tenant.Languages.Default);

                // Alternate Languages
                foreach (var language in tenant.Languages.Alternate)
                {
                    tenantNode.SetCultureName($"{nodeName}-{language}", language.Trim());
                }

                // Set values for node
                tenantNode.SetValue("brandName", tenant.BrandName);
                tenantNode.SetValue("tenantUid", tenant.TenantUId);
                tenantNode.SetValue("domain", tenant.Domain);
                tenantNode.SetValue("subDomain", tenant.SubDomain);
                tenantNode.SetValue("helpdeskTelegramAccount", tenant.HelpdeskTelegramAccount);
                tenantNode.SetValue("apiKey", tenant.ApiKey);
                tenantNode.SetValue("appId", tenant.AppId);
                tenantNode.SetValue("defaultLanguage", tenant.Languages.Default);
                tenantNode.SetValue("tenantCurrencies", string.Join(",", tenant.Currencies.Codes));
                tenantNode.SetValue("tenantStatus", ENABLED);
                tenantNode.SetValue("languages", string.Join(", ", tenant.Languages.Alternate.ToList()));
                tenantNode.SetValue("tenantPreferencesProperty", JsonConvert.SerializeObject(tenant.TenantPreferences));

                tenantNode.SetValue("metaAuthor", "نیتروبت", tenant.Languages.Default);
                tenantNode.SetValue("metaCopyright", "کلیه حقوق برای بت و برد محفوظ است", tenant.Languages.Default);
                tenantNode.SetValue("metaDescription", "پیش بینی مسابقات ورزشی با بهترین ضرایب به صورت زنده و پیش از بازی روی تمامی ورزشها معتبر جهان. با بهترین خدمات پس از فروش و پرداخت سریع جوایز", tenant.Languages.Default);

                //tenantNode.SetValue("paymentSettingsProperty", JsonConvert.SerializeObject(tenant.PaymentSettings));

                contentService.Save(tenantNode);

                ConnectorContext.AuditService.Add(AuditType.New, -1, tenantNode.Id, "Content Node", $"ContentNode for {tenant.TenantUId} has been created");
                return(tenantNode.Id);
            }
            catch (Exception ex)
            {
                logger.Error(typeof(HomeContentNode), ex.Message);
                logger.Error(typeof(HomeContentNode), ex.StackTrace);
                throw;
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Method to create an IContent object based on the Udi of a parent
        /// </summary>
        /// <param name="contentService"></param>
        /// <param name="name"></param>
        /// <param name="parentId"></param>
        /// <param name="contentTypeAlias"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public static IContent CreateContent(this IContentService contentService, string name, Udi parentId, string contentTypeAlias, int userId = Constants.Security.SuperUserId)
        {
            var guidUdi = parentId as GuidUdi;

            if (guidUdi is null)
            {
                throw new InvalidOperationException("The UDI provided isn't of type " + typeof(GuidUdi) + " which is required by content");
            }
            var parent = contentService.GetById(guidUdi.Guid);

            return(contentService.Create(name, parent, contentTypeAlias, userId));
        }
Esempio n. 22
0
        protected override Attempt <IContent> CreateItem(string alias, ITreeEntity parent, string itemType)
        {
            var parentId = parent != null ? parent.Id : -1;
            var item     = contentService.Create(alias, parentId, itemType);

            if (item == null)
            {
                return(Attempt.Fail(item, new ArgumentException($"Unable to create content item of type {itemType}")));
            }

            return(Attempt.Succeed(item));
        }
Esempio n. 23
0
        public static IContent CreateWithInvariantOrDefaultCultureName(
            this IContentService contentService,
            string name,
            int parent,
            IContentTypeComposition contentType,
            ILocalizationService localizationService,
            int userId = -1)
        {
            var content = contentService.Create(name, parent, contentType.Alias, userId);

            content.SetInvariantOrDefaultCultureName(name, contentType, localizationService);
            return(content);
        }
Esempio n. 24
0
        /// <inheritdoc />
        public IContent CreateBlock(CreateBlockRequest createRequest, CancellationToken cancellationToken)
        {
            // Get parent content
            var parentContent = _contentService.GetById(createRequest.parentId);
            // Create new block as child of parent content.
            // Use a random Guid to generate temporary name
            var content = _contentService.Create(createRequest.ContentType + $":{Guid.NewGuid()}", parentContent.Id, createRequest.ContentType);

            // Once the content item has been created, update the name by replacing the random Guid with the Guid generated by umbraco
            content.Name = createRequest.ContentType + $":{content.Key}";
            _contentService.SaveAndPublish(content);
            return(content);
        }
Esempio n. 25
0
        public void ReadExcelFileSax(string fileName, IContent e)
        {
            using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(fileName, false))
            {
                WorkbookPart  workbookPart  = spreadsheetDocument.WorkbookPart;
                WorksheetPart worksheetPart = workbookPart.WorksheetParts.First();

                SharedStringTablePart sstpart = workbookPart.GetPartsOfType <SharedStringTablePart>().First();
                SharedStringTable     sst     = sstpart.SharedStringTable;

                var sheets         = workbookPart.Workbook.Sheets.Cast <Sheet>().ToList();
                var worksheetParts = workbookPart.WorksheetParts;
                worksheetParts = worksheetParts.OrderBy(w => sheets.IndexOf(sheets.Where(x => x.Id.Value == spreadsheetDocument.WorkbookPart.GetIdOfPart(w)).First()));

                OpenXmlReader reader = OpenXmlReader.Create(workbookPart);

                string    text  = string.Empty;
                Worksheet sheet = worksheetPart.Worksheet;
                var       rows  = sheet.Descendants <Row>().Skip(1);

                foreach (Row row in rows)
                {
                    var celdas = row.Elements <Cell>().ToArray();
                    if (celdas[0].CellValue != null)
                    {
                        var Nombre      = sst.ChildElements[int.Parse(celdas[1].CellValue.Text)].InnerText;
                        var Descripcion = sst.ChildElements[int.Parse(celdas[2].CellValue.Text)].InnerText;
                        var Sinonimos   = sst.ChildElements[int.Parse(celdas[1].CellValue.Text)].InnerText;
                        //var Fecha = DateTime.Parse(sst.ChildElements[int.Parse(celdas[1].CellValue.Text)].InnerText);
                        var content = _prueba.Create(Nombre, e.Id, "slangs");
                        content.SetValue("descripcion", Descripcion);
                        content.SetValue("sinonimos", Sinonimos);
                        //content.SetValue("fechaPublicacion", Fecha);
                        _prueba.SaveAndPublish(content, "*", -1, false);
                    }
                    else
                    {
                        break;
                    }
                }

                /*while (reader.Read())
                 * {
                 *  text = reader.GetText();
                 *  var content = _prueba.Create("My First Blog Post 2", e.Id, "slangs");
                 *
                 *  content.SetValue("descripcion", text);
                 *  _prueba.SaveAndPublish(content, "*", -1, false);
                 * }*/
            }
        }
Esempio n. 26
0
        /// <summary>
        /// creates node under the provided parentKey for the member
        /// </summary>
        /// <param name="member"></param>
        /// <param name="parentKey"></param>
        /// <returns></returns>
        private IContent CreateNode(IMember member, string parentKey)
        {
            var node = _contentService.Create(member.Username, Guid.Parse(parentKey), Published.Physiotherapist.ModelTypeAlias);

            node.SetValue(GetPhysioPropsAlias(x => x.Physio_name), member.Name);
            node.SetValue(GetPhysioPropsAlias(x => x.Physio_email), member.Email);

            var address = GetUmbracoPropertyValue(member.Properties, GetMemberPropsAlias(m => m.Address));
            var phone   = GetUmbracoPropertyValue(member.Properties, GetMemberPropsAlias(m => m.Phone));

            node.SetValue(GetPhysioPropsAlias(x => x.Physio_address), address);
            node.SetValue(GetPhysioPropsAlias(x => x.Physio_contact), phone);

            _contentService.SaveAndPublish(node);

            return(node);
        }
Esempio n. 27
0
        private void CreatePage(Page page)
        {
            var node = _ContentService.Create(page.Name, page.Parent, page.ContentTypeAlias);

            foreach (var prop in page.DocumentProperties)
            {
                node.SetValue(prop.Key, prop.Value);
            }


            // This is an issue with Umbraco 8 publishing nodes on start-up
            // https://github.com/umbraco/Umbraco-CMS/issues/5281
            using (_ContextFactory.EnsureUmbracoContext())
            {
                _ContentService.SaveAndPublish(node, raiseEvents: false);
                page.Id = node.Id;
            }
        }
        private void AddNewEpisode(EpisodeModel spreakerEpisode, EpisodesFolder cmsEpisodesFolder)
        {
            var cmsEpisode = _contentService.Create(spreakerEpisode.Title, cmsEpisodesFolder.Id, Episode.ModelTypeAlias, -1);

            cmsEpisode.SetValue("spreakerId", spreakerEpisode.Id);
            cmsEpisode.SetValue("podcastTitle", spreakerEpisode.Title);
            cmsEpisode.SetValue("podcastLink", spreakerEpisode.PlaybackUrl);
            cmsEpisode.SetValue("showNotes", spreakerEpisode.Description);
            cmsEpisode.SetValue("publishedDate", spreakerEpisode.PublishedDate);
            cmsEpisode.SetValue("listensCount", spreakerEpisode.GetListens());

            // try and set the correct title for displaying on web page
            // format should be either Episode X: title, or SX EpY: Episode
            if (spreakerEpisode.Title.Contains(":"))
            {
                cmsEpisode.SetValue("displayTitle", spreakerEpisode.Title.Split(':')[1].Trim());
            }

            _contentService.SaveAndPublish(cmsEpisode);
        }
Esempio n. 29
0
        public ActionResult Update(CommentViewModel viewModel, int?returnPageId)
        {
            var user = new AppUser
            {
                Id = User.Identity.GetUserId <int>()
            };
            var topic = new Topic
            {
                Id = viewModel.TopicId
            };
            var comment = new Comment
            {
                Message = viewModel.Message,
                Id      = viewModel.Id,
                Topic   = topic,
                User    = user
            };

            if (viewModel.Id == 0)
            {
                commentService.Create(user, comment);
            }
            else
            {
                commentService.Update(user, comment);
            }

            object routeValues;

            if (returnPageId != null)
            {
                routeValues = new { id = viewModel.TopicId, page = returnPageId };
            }
            else
            {
                routeValues = new { id = viewModel.TopicId };
            }

            return(RedirectToAction("Index", "Topic", routeValues));
        }
Esempio n. 30
0
        public int CreateResetPasswordPage(Tenant tenant)
        {
            var home    = TenantHelper.GetCurrentTenantHome(contentService, tenant.TenantUId.ToString());
            var docType = contentTypeService.Get(_07_ResetPasswordViaEmailDocumentType.DOCUMENT_TYPE_ALIAS);

            try
            {
                var nodeName = "Reset Password";

                IContent resetPasswordNode = contentService.Create(nodeName, home.Id, _07_ResetPasswordViaEmailDocumentType.DOCUMENT_TYPE_ALIAS);
                resetPasswordNode.Name = nodeName;
                resetPasswordNode.SetCultureName(nodeName, tenant.Languages.Default);
                if (tenant.Languages.Default == "fa")
                {
                    resetPasswordNode.SetCultureName("بازیابی کلمه عبور", tenant.Languages.Default);
                }

                // Alternate Languages
                foreach (var language in tenant.Languages.Alternate)
                {
                    resetPasswordNode.SetCultureName($"{nodeName}-{language}", language.Trim());
                    if (language.Trim() == "fa")
                    {
                        resetPasswordNode.SetCultureName("بازیابی کلمه عبور", language.Trim());
                    }
                }

                contentService.Save(resetPasswordNode);

                ConnectorContext.AuditService.Add(AuditType.New, -1, resetPasswordNode.Id, "Content Node", $"ContentNode for {tenant.TenantUId.ToString()} has been created");
                return(resetPasswordNode.Id);
            }
            catch (Exception ex)
            {
                logger.Error(typeof(ResetPasswordContentNode), ex.Message);
                logger.Error(typeof(ResetPasswordContentNode), ex.StackTrace);
                throw;
            }
        }