Beispiel #1
0
 //We can add an existing product too
 public Boolean AddEditor(Editor editor)
 {
     var editorBl = new EditorBL();
     if (editorBl.IsEditorExist(editor.GetUserName()))
     {
         return false;
     }
     _editorDal.AddEditor(editor);
     return true;
 }
        public void AddEditor(Editor editor)
        {
            var conn = new SqlConnection(GetConnectionString());
            var sql = "INSERT INTO Editors VALUES('" + editor.GetFirstName().Trim() + "','" + editor.GetLastName().Trim() + "','" + editor.GetUserName().Trim() + "','" + editor.GetPassword().Trim() + "','" + editor.GetEmail().Trim() + "','" + editor.GetAuthorized() + "')";
            try
            {
                conn.Open();
                var cmd = new SqlCommand(sql, conn);

                cmd.ExecuteNonQuery();
            }
            catch (SqlException ex)
            {
                var msg = "AddEditor Sql Error: ";
                msg += ex.Message;
                throw new Exception(msg);
            }
            finally
            {
                conn.Close();
            }
        }