Example #1
0
        public async Task <ActionResult> add_attr()
        {
            var json = new StreamReader(Request.Body).ReadToEnd();
            var attr = JsonConvert.DeserializeObject <JGN_Attr_Attributes>(json);

            // attr.attr_type = (byte)AttrAttributeBLL.Attr_Type.Ad;

            if (attr.id > 0)
            {
                // update attribute
                await AttrAttributeBLL.Update(_context, attr);
            }
            else
            {
                attr = await AttrAttributeBLL.Add(_context, attr);
            }

            return(Ok(new { status = "success", record = attr, message = SiteConfig.generalLocalizer["_records_processed"].Value }));
        }
        /// <summary>
        /// Add pre-defined section and few default attributes for user dynamic profile, for more control visit control panel -> users -> settings section.
        /// </summary>
        /// <param name="context"></param>
        public static async Task InitializeUserProfileDynamicAttributes(ApplicationDbContext context)
        {
            // Add default section to manage all user profile dynamic attributes
            if (await AttrTemplatesSectionsBLL.Count(context, new AttrTemplateSectionEntity()
            {
                attr_type = Attr_Type.UserProfile
            }) == 0)
            {
                var Sections = new List <JGN_Attr_TemplateSections>
                {
                    new JGN_Attr_TemplateSections {
                        title = "General", attr_type = (byte)Attr_Type.UserProfile, priority = 100, showsection = 0
                    },
                };


                foreach (var Section in Sections)
                {
                    var output = await AttrTemplatesSectionsBLL.Add(context, Section);

                    // Add few pre-defined user profile attributes. for more visit control panel -> users -> settings section
                    var Attributes = new List <JGN_Attr_Attributes>
                    {
                        new JGN_Attr_Attributes {
                            sectionid     = output.id,
                            title         = "About Me",
                            value         = "",
                            attr_type     = (byte)Attr_Type.UserProfile,
                            options       = "",
                            element_type  = 5, // rich text editor
                            isrequired    = 0,
                            variable_type = 0,
                            icon          = "0",
                            helpblock     = "Enter your brief bio.",
                            min           = 0,
                            max           = 0,
                            priority      = 100
                        },
                        new JGN_Attr_Attributes {
                            sectionid     = output.id,
                            title         = "Website",
                            value         = "",
                            attr_type     = (byte)Attr_Type.UserProfile,
                            options       = "",
                            element_type  = 0, // textbox
                            isrequired    = 0,
                            variable_type = 0,
                            icon          = "0",
                            helpblock     = "Enter website",
                            min           = 0,
                            max           = 0,
                            priority      = 99
                        },
                        new JGN_Attr_Attributes {
                            sectionid     = output.id,
                            title         = "City",
                            value         = "City",
                            attr_type     = (byte)Attr_Type.UserProfile,
                            options       = "",
                            element_type  = 0, // textbox
                            isrequired    = 0,
                            variable_type = 0,
                            icon          = "0",
                            helpblock     = "Enter city",
                            min           = 0,
                            max           = 0,
                            priority      = 98
                        }
                    };

                    foreach (var Attribute in Attributes)
                    {
                        await AttrAttributeBLL.Add(context, Attribute);
                    }
                }
            }
        }