Exemple #1
0
        public static FormInfo CreateDefaultForm(int siteId, int channelId, int contentId)
        {
            var formInfo = new FormInfo
            {
                SiteId       = siteId,
                ChannelId    = channelId,
                ContentId    = contentId,
                Title        = "默认表单",
                Description  = string.Empty,
                IsReply      = false,
                RepliedCount = 0,
                TotalCount   = 0,
                AddDate      = DateTime.Now,
                Additional   = new FormSettings(string.Empty)
            };

            formInfo.Id = Insert(formInfo);

            FieldDao.Insert(siteId, new FieldInfo
            {
                FormId      = formInfo.Id,
                Title       = "姓名",
                PlaceHolder = "请输入您的姓名",
                FieldType   = InputType.Text.Value,
                Validate    = "required",
                Settings    = string.Empty
            });
            FieldDao.Insert(siteId, new FieldInfo
            {
                FormId      = formInfo.Id,
                Title       = "手机",
                PlaceHolder = "请输入您的手机号码",
                FieldType   = InputType.Text.Value,
                Validate    = "mobile",
                Settings    = string.Empty
            });
            FieldDao.Insert(siteId, new FieldInfo
            {
                FormId      = formInfo.Id,
                Title       = "邮箱",
                PlaceHolder = "请输入您的电子邮箱",
                FieldType   = InputType.Text.Value,
                Validate    = "email",
                Settings    = string.Empty
            });

            FieldDao.Insert(siteId, new FieldInfo
            {
                FormId      = formInfo.Id,
                Title       = "留言",
                PlaceHolder = "请输入您的留言",
                Validate    = "required",
                FieldType   = InputType.TextArea.Value
            });

            return(formInfo);
        }
Exemple #2
0
        public static void Delete(int siteId, int formId)
        {
            if (formId <= 0)
            {
                return;
            }

            var sqlString = $"DELETE FROM {TableName} WHERE {nameof(FormInfo.Id)} = {formId}";

            Context.DatabaseApi.ExecuteNonQuery(Context.ConnectionString, sqlString);

            FieldDao.DeleteByFormId(formId);
            LogDao.DeleteByFormId(formId);

            FormManager.ClearCache(siteId);
        }