Exemple #1
0
 public bool Add(ContactUs info)
 {
     bool result = false;
     try
     {
         result = WriteContactUs(ProceduresNames.ContactUsAdd, info);
     }
     catch (Exception error)
     {
         throw error;
     }
     return result;
 }
Exemple #2
0
        private bool WriteContactUs(string ProcedureName, ContactUs info)
        {
            bool result = false;
            try
            {
                SqlCommand command = new SqlCommand(ProcedureName, this.Connection);
                command.CommandType = CommandType.StoredProcedure;

                command.Parameters.Add(string.Concat(CommonStrings.AtSymbol, ContactUs.CommonColumns.ID), SqlDbType.Int);
                command.Parameters[string.Concat(CommonStrings.AtSymbol, ContactUs.CommonColumns.ID)].Direction = ParameterDirection.Output;

                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.TableColumns.Title), info.Title);
                command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.TableColumns.Description), info.Description);

                if (!string.IsNullOrEmpty(info.Name))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.TableColumns.Name), info.Name);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.TableColumns.Name), DBNull.Value);

                if (!string.IsNullOrEmpty(info.Email))
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.TableColumns.Email), info.Email);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.TableColumns.Email), DBNull.Value);

                if (info.CreatedBy.HasValue)
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.CommonColumns.CreatedBy), info.CreatedBy.Value);
                else
                    command.Parameters.AddWithValue(string.Concat(CommonStrings.AtSymbol, ContactUs.CommonColumns.CreatedBy), DBNull.Value);

                this.OpenConnection();

                command.ExecuteNonQuery();

                info.ID = Convert.ToInt32(command.Parameters[string.Concat(CommonStrings.AtSymbol, ContactUs.CommonColumns.ID)].Value);

                result = true;
            }
            catch (Exception error)
            {
                throw error;
            }
            finally
            {
                this.CloseConnection();
            }
            return result;
        }
Exemple #3
0
        private void ReadContactUsList(SqlDataReader reader, List<ContactUs> infoList)
        {
            try
            {
                ContactUs info = null;

                while (reader.Read())
                {
                    info = new ContactUs();

                    info.ID = Convert.ToInt32(reader[ContactUs.CommonColumns.ID]);
                    info.Title = Convert.ToString(reader[ContactUs.TableColumns.Title]);
                    info.Description = Convert.ToString(reader[ContactUs.TableColumns.Description]);
                    info.IsNew = Convert.ToBoolean(reader[ContactUs.TableColumns.IsNew]);
                    info.CreationDate = Convert.ToDateTime(reader[ContactUs.CommonColumns.CreationDate]);
                    info.IsReplied = Convert.ToBoolean(reader[ContactUs.TableColumns.IsReplied]);
                    info.IsClosed = Convert.ToBoolean(reader[ContactUs.TableColumns.IsClosed]);

                    if (reader[ContactUs.CommonColumns.CreatedBy] != DBNull.Value)
                        info.CreatedBy = (Guid)reader[ContactUs.CommonColumns.CreatedBy];
                    else
                        info.CreatedBy = null;

                    if (reader[ContactUs.TableColumns.Name] != DBNull.Value)
                        info.Name = Convert.ToString(reader[ContactUs.TableColumns.Name]);

                    if (reader[ContactUs.TableColumns.Email] != DBNull.Value)
                        info.Email = Convert.ToString(reader[ContactUs.TableColumns.Email]);

                    if (reader[ContactUs.TableColumns.RepliedBy] != DBNull.Value)
                        info.RepliedBy = (Guid)reader[ContactUs.TableColumns.RepliedBy];
                    else
                        info.RepliedBy = null;

                    if (reader[ContactUs.TableColumns.ReplyDate] != DBNull.Value)
                        info.ReplyDate = Convert.ToDateTime(reader[ContactUs.TableColumns.ReplyDate]);
                    else
                        info.ReplyDate = null;

                    if (reader[ContactUs.TableColumns.Reply] != DBNull.Value)
                        info.Reply = Convert.ToString(reader[ContactUs.TableColumns.Reply]);

                    if (reader[ContactUs.TableColumns.ClosedBy] != DBNull.Value)
                        info.ClosedBy = (Guid)reader[ContactUs.TableColumns.ClosedBy];
                    else
                        info.ClosedBy = null;

                    if (reader[ContactUs.TableColumns.CloseDate] != DBNull.Value)
                        info.CloseDate = Convert.ToDateTime(reader[ContactUs.TableColumns.CloseDate]);
                    else
                        info.CloseDate = null;

                    infoList.Add(info);
                }
            }
            catch (Exception error)
            {
                throw error;
            }
        }