Пример #1
0
        public int Add(TEntityType item)
        {
            var props = typeof(TEntityType).GetProperties()
                        .Where(
                x => x.CustomAttributes.
                All(y => y.GetType() == typeof(AutoCalculate) ||
                    y.GetType() == typeof(EntityKey) ||
                    y.GetType() == typeof(NonPersisted)) &&
                !x.GetMethod.IsVirtual
                );
            var attributes    = from m in props select m.Name;
            var parameterlist = from m in attributes select "@" + m;

            string cmd = "insert into " + item.GetType().Name +
                         "(" + String.Join(",", attributes) + ")" + "values(" +
                         string.Join(",", parameterlist) + ")";

            var MyType = typeof(TEntityType);
            List <SqlParameter> sqlParameters = new List <SqlParameter>();

            foreach (var attr in attributes)
            {
                PropertyInfo prop  = MyType.GetProperty(attr);
                object       value = prop.GetValue(item);
                sqlParameters.Add(new SqlParameter(attr, value));
            }
            return(SqlHelpers.Insert(_connection, cmd, sqlParameters));
        }
Пример #2
0
        protected void SendMessage_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
            _ = SqlHelpers.Insert(SqlStatements.SQL_INSERT_NEWSLETTER_ADDRESS.FormatWith(ContactName.Text.Trim().FixSqlString(), ContactEmail.Text.Trim().FixSqlString()));
            var msg = new MailMessage {
                IsBodyHtml = false,
                From       = new MailAddress(ContactEmail.Text.Trim(), ContactName.Text.Trim()),
                Subject    = "[New Resource Link] Please add this resource link",
                Body       = "I would like to submit the following link to be added as a resource\n\n{0}\n\nThanks {1}".FormatWith(ContactSubject.Text.Trim(), ContactName.Text.Trim())
            };

            msg.To.Add(new MailAddress("*****@*****.**", "USFarmExchange Contact Service"));
            SessionInfo.SendContactEmail(ref msg);
        }
Пример #3
0
        protected void SendMessage_Click(object sender, EventArgs e)
        {
            if (!Page.IsValid)
            {
                return;
            }
            _ = SqlHelpers.Insert(SqlStatements.SQL_INSERT_NEWSLETTER_ADDRESS.FormatWith(ContactName.Text.Trim().FixSqlString(), ContactEmail.Text.Trim().FixSqlString()));
            var msg = new MailMessage {
                IsBodyHtml = false,
                From       = new MailAddress(ContactEmail.Text.Trim(), ContactName.Text.Trim()),
                Subject    = ContactSubject.Text.Trim(),
                Body       = ContactMessage.Text.Trim()
            };

            msg.To.Add(new MailAddress("*****@*****.**", "USFarmExchange Contact Service"));
            SessionInfo.SendContactEmail(ref msg);
        }