Esempio n. 1
0
        public Field CreateField(Field field, Template template)
        {
            field = _fieldrepository.CreateField(field, template);
            _fieldrepository.AddFieldToTemplate(template, field);
            //template = _templaterepository.GetTemplate(template);  // this doesnot always retrieve all Nodes in case if browser is not refreshed after noder creation, hence its not safe.
            var fields = new List <Field>()
            {
                field
            };
            var nodes = _base.GetByCondition(x => x.TemplateId == template.Id);

            // add the template to the ndoe list.
            nodes.Add(new Node()
            {
                Id = template.Id
            });                                         // every template's id is same as to it corresponding Node's Id.
            foreach (var node in nodes)
            {
                ((INodeRepository)_currentrepository).RegisterFieldsForNode(node, fields);
            }
            return(field);
        }